Merge heads

This commit is contained in:
youtaol
2012-09-19 20:06:00 +08:00
3 changed files with 31 additions and 31 deletions
@@ -257,7 +257,7 @@ public class CreateAndSendTrackTest extends ActivityInstrumentationTestCase2<Tra
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.send_google_send_now), EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.send_google_send_now),
true, true); true, true);
if(!GoogleUtils.checkAccountStatusDialog()) { if(!GoogleUtils.isAccountAvailable()) {
return; return;
} }
@@ -368,7 +368,7 @@ public class GoogleUtils {
* *
* @return true means the status of account is good for sending * @return true means the status of account is good for sending
*/ */
public static boolean checkAccountStatusDialog() { public static boolean isAccountAvailable() {
// Check whether no account is binded with this device. // Check whether no account is binded with this device.
if (EndToEndTestUtils.SOLO.waitForText( if (EndToEndTestUtils.SOLO.waitForText(
EndToEndTestUtils.activityMytracks.getString(R.string.send_google_no_account_title), 1, EndToEndTestUtils.activityMytracks.getString(R.string.send_google_no_account_title), 1,
@@ -36,6 +36,7 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
private Instrumentation instrumentation; private Instrumentation instrumentation;
private TrackListActivity activityMyTracks; private TrackListActivity activityMyTracks;
private final static String SHARE_ITEM_PARENT_VIEW_NAME = "RecycleListView";
@TargetApi(8) @TargetApi(8)
public MenuItemsTest() { public MenuItemsTest() {
@@ -99,8 +100,9 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
* Tests the share menu item. This test to check whether crash will happen during the share. * Tests the share menu item. This test to check whether crash will happen during the share.
*/ */
public void testShareActivity() { public void testShareActivity() {
// Try all share item. // Try all share items.
for (int i = 0;; i++) { for (int i = 0;; i++) {
EndToEndTestUtils.createTrackIfEmpty(0, false);
View oneItemView = findShareItem(i); View oneItemView = findShareItem(i);
if (oneItemView == null) { if (oneItemView == null) {
break; break;
@@ -108,7 +110,7 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
EndToEndTestUtils.SOLO.clickOnView(oneItemView); EndToEndTestUtils.SOLO.clickOnView(oneItemView);
EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true, EndToEndTestUtils.getButtonOnScreen(activityMyTracks.getString(R.string.generic_ok), true,
true); true);
if(!GoogleUtils.checkAccountStatusDialog()) { if(!GoogleUtils.isAccountAvailable()) {
break; break;
} }
// Waiting the send is finish. // Waiting the send is finish.
@@ -131,18 +133,18 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
/** /**
* Gets the view to click the share item by item index. * Gets the view to click the share item by item index.
*
* @param index of a share item * @param index of a share item
* @return null when no such item * @return null when no such item
*/ */
private View findShareItem(int index) { private View findShareItem(int index) {
EndToEndTestUtils.createTrackIfEmpty(0, false);
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_share), true); EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_share), true);
ArrayList<View> cc = EndToEndTestUtils.SOLO.getViews(); ArrayList<View> views = EndToEndTestUtils.SOLO.getViews();
int i = 0; int i = 0;
for (View view : cc) { for (View view : views) {
String name = view.getParent().getClass().getName(); String name = view.getParent().getClass().getName();
// Each share item is in one Linear layout which is the child view of // Each share item is a child of a "RecycleListView"
if (name.indexOf("RecycleListView") > 0) { if (name.indexOf(SHARE_ITEM_PARENT_VIEW_NAME) > 0) {
if (index == i) { if (index == i) {
return view; return view;
} }
@@ -153,11 +155,27 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
} }
/** /**
* Checks the voice frequency and split frequency menus when no track is * Checks the voice frequency and split frequency menus during recording. When
* recording. * recording, they should be in both the menu and the recording settings. When
* not recording, they should only be in the recording settings.
*/ */
public void testFrequencyMenu_noRecording() { public void testFrequencyMenu() {
EndToEndTestUtils.createTrackIfEmpty(0, false); EndToEndTestUtils.startRecording();
assertTrue(EndToEndTestUtils.findMenuItem(
activityMyTracks.getString(R.string.menu_voice_frequency), false));
assertTrue(EndToEndTestUtils.findMenuItem(
activityMyTracks.getString(R.string.menu_split_frequency), false));
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_recording));
assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks.getString(R.string.menu_voice_frequency), 1, true, true));
assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks.getString(R.string.menu_split_frequency), 1, true, true));
EndToEndTestUtils.SOLO.goBack();
EndToEndTestUtils.SOLO.goBack();
EndToEndTestUtils.stopRecording(true);
assertFalse(EndToEndTestUtils.findMenuItem( assertFalse(EndToEndTestUtils.findMenuItem(
activityMyTracks.getString(R.string.menu_voice_frequency), false)); activityMyTracks.getString(R.string.menu_voice_frequency), false));
assertFalse(EndToEndTestUtils.findMenuItem( assertFalse(EndToEndTestUtils.findMenuItem(
@@ -165,28 +183,10 @@ public class MenuItemsTest extends ActivityInstrumentationTestCase2<TrackListAct
EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true); EndToEndTestUtils.findMenuItem(activityMyTracks.getString(R.string.menu_settings), true);
EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_recording)); EndToEndTestUtils.SOLO.clickOnText(activityMyTracks.getString(R.string.settings_recording));
assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks.getString(R.string.menu_voice_frequency), 1, true, true)); assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks.getString(R.string.menu_voice_frequency), 1, true, true));
assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks.getString(R.string.menu_split_frequency), 1, true, true)); assertTrue(EndToEndTestUtils.SOLO.searchText(activityMyTracks.getString(R.string.menu_split_frequency), 1, true, true));
} }
/**
* Checks the voice frequency and split frequency menus during recording.
*/
public void testFrequencyMenu_underRecording() {
EndToEndTestUtils.startRecording();
assertTrue(EndToEndTestUtils.findMenuItem(
activityMyTracks.getString(R.string.menu_voice_frequency), false));
assertTrue(EndToEndTestUtils.findMenuItem(
activityMyTracks.getString(R.string.menu_split_frequency), false));
EndToEndTestUtils.stopRecording(true);
assertFalse(EndToEndTestUtils.findMenuItem(
activityMyTracks.getString(R.string.menu_voice_frequency), false));
assertFalse(EndToEndTestUtils.findMenuItem(
activityMyTracks.getString(R.string.menu_split_frequency), false));
}
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
EndToEndTestUtils.SOLO.finishOpenedActivities(); EndToEndTestUtils.SOLO.finishOpenedActivities();