Commit ae366fd6 authored by John Mellor's avatar John Mellor Committed by Commit Bot

Revert "Convert TabsTests and IncognitoNotificationServiceTest to JUnit4"

This reverts commit 793d799b.

Reason for revert - made TabsTest very flaky on the following bots:
https://build.chromium.org/p/chromium.android/builders/Lollipop%20Phone%20Tester/builds/15045
https://build.chromium.org/p/chromium.linux/builders/Android%20Tests%20(dbg)/builds/45549

Original change's description:
> Convert TabsTests and IncognitoNotificationServiceTest to JUnit4
> 
> For more on JUnit4 migration, please check src/testing/android/docs/junit4.md
> 
> Bug: 640116
> Change-Id: I508ee1b6512a4a96175d1747a0f8ebe1764f11e6
> Reviewed-on: https://chromium-review.googlesource.com/662241
> Commit-Queue: Yoland Yan <yolandyan@chromium.org>
> Reviewed-by: Ted Choc <tedchoc@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#501446}

TBR=tedchoc@chromium.org,yolandyan@chromium.org

Change-Id: I86ba1b7776b734a9150a09a3b6994c46732ac1e4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 640116
Reviewed-on: https://chromium-review.googlesource.com/664717Reviewed-by: default avatarJohn Mellor <johnme@chromium.org>
Commit-Queue: John Mellor <johnme@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501593}
parent e095db10
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -7,30 +7,20 @@ package org.chromium.chrome.browser.incognito;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest;
import android.util.Pair;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.ThreadUtils;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.TabState;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
import org.chromium.chrome.browser.tabmodel.TabPersistentStore;
import org.chromium.chrome.browser.tabmodel.TestTabModelDirectory;
import org.chromium.chrome.browser.tabmodel.TestTabModelDirectory.TabStateInfo;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.LoadUrlParams;
......@@ -41,37 +31,36 @@ import java.util.concurrent.Callable;
/**
* Tests for the Incognito Notification service.
*/
@RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({
ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG,
})
public class IncognitoNotificationServiceTest {
@Rule
public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActivityTestRule();
public class IncognitoNotificationServiceTest extends ChromeTabbedActivityTestBase {
@Override
public void startMainActivity() throws InterruptedException {
// Each test will start its own activity as needed.
}
private void createTabOnUiThread() {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
mActivityTestRule.getActivity().getTabCreator(true).createNewTab(
new LoadUrlParams("about:blank"), TabLaunchType.FROM_CHROME_UI, null);
getActivity().getTabCreator(true).createNewTab(new LoadUrlParams("about:blank"),
TabLaunchType.FROM_CHROME_UI, null);
}
});
}
private void sendClearIncognitoIntent() throws CanceledException {
PendingIntent clearIntent = IncognitoNotificationService.getRemoveAllIncognitoTabsIntent(
InstrumentationRegistry.getTargetContext());
PendingIntent clearIntent =
IncognitoNotificationService.getRemoveAllIncognitoTabsIntent(
getInstrumentation().getTargetContext());
clearIntent.send();
}
@Test
@Feature("Incognito")
@MediumTest
public void testSingleRunningChromeTabbedActivity()
throws InterruptedException, CanceledException {
mActivityTestRule.startMainActivityOnBlankPage();
startMainActivityOnBlankPage();
createTabOnUiThread();
createTabOnUiThread();
......@@ -79,10 +68,7 @@ public class IncognitoNotificationServiceTest {
CriteriaHelper.pollUiThread(Criteria.equals(2, new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return mActivityTestRule.getActivity()
.getTabModelSelector()
.getModel(true)
.getCount();
return getActivity().getTabModelSelector().getModel(true).getCount();
}
}));
......@@ -90,17 +76,14 @@ public class IncognitoNotificationServiceTest {
new Callable<Profile>() {
@Override
public Profile call() throws Exception {
return mActivityTestRule.getActivity()
.getTabModelSelector()
.getModel(true)
.getProfile();
return getActivity().getTabModelSelector().getModel(true).getProfile();
}
});
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
Assert.assertTrue(incognitoProfile.isOffTheRecord());
Assert.assertTrue(incognitoProfile.isNativeInitialized());
assertTrue(incognitoProfile.isOffTheRecord());
assertTrue(incognitoProfile.isNativeInitialized());
}
});
......@@ -109,10 +92,7 @@ public class IncognitoNotificationServiceTest {
CriteriaHelper.pollUiThread(Criteria.equals(0, new Callable<Integer>() {
@Override
public Integer call() throws Exception {
return mActivityTestRule.getActivity()
.getTabModelSelector()
.getModel(true)
.getCount();
return getActivity().getTabModelSelector().getModel(true).getCount();
}
}));
CriteriaHelper.pollUiThread(new Criteria() {
......@@ -123,12 +103,11 @@ public class IncognitoNotificationServiceTest {
});
}
@Test
@Feature("Incognito")
@MediumTest
@RetryOnFailure
public void testNoAliveProcess() throws Exception {
Context context = InstrumentationRegistry.getInstrumentation().getTargetContext();
Context context = getInstrumentation().getTargetContext();
final TestTabModelDirectory tabbedModeDirectory = new TestTabModelDirectory(
context, "tabs", String.valueOf(0));
......@@ -153,8 +132,8 @@ public class IncognitoNotificationServiceTest {
TabPersistentStore.setBaseStateDirectoryForTests(tabbedModeDirectory.getBaseDirectory());
File[] tabbedModeFiles = tabbedModeDirectory.getDataDirectory().listFiles();
Assert.assertNotNull(tabbedModeFiles);
Assert.assertEquals(5, tabbedModeFiles.length);
assertNotNull(tabbedModeFiles);
assertEquals(5, tabbedModeFiles.length);
int incognitoCount = 0;
int normalCount = 0;
......@@ -164,8 +143,8 @@ public class IncognitoNotificationServiceTest {
if (tabFileInfo.second) incognitoCount++;
else normalCount++;
}
Assert.assertEquals(2, normalCount);
Assert.assertEquals(3, incognitoCount);
assertEquals(2, normalCount);
assertEquals(3, incognitoCount);
sendClearIncognitoIntent();
......@@ -202,8 +181,9 @@ public class IncognitoNotificationServiceTest {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
Assert.assertFalse(LibraryLoader.isInitialized());
assertFalse(LibraryLoader.isInitialized());
}
});
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment