Index: chrome/android/javatests/src/org/chromium/chrome/browser/ProcessIsolationTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/ProcessIsolationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/ProcessIsolationTest.java |
index 513f2cd7a1bb567f44b89abba6d6a879419a873c..bc21ffe2fdafa97fa4aa0dc77b2710780d6bc10c 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/ProcessIsolationTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/ProcessIsolationTest.java |
@@ -7,19 +7,11 @@ |
import android.support.test.filters.MediumTest; |
import android.text.TextUtils; |
-import org.junit.Assert; |
-import org.junit.Before; |
-import org.junit.Rule; |
-import org.junit.Test; |
-import org.junit.runner.RunWith; |
- |
import org.chromium.base.BuildInfo; |
-import org.chromium.base.test.util.CommandLineFlags; |
import org.chromium.base.test.util.DisableIf; |
import org.chromium.base.test.util.Feature; |
import org.chromium.base.test.util.RetryOnFailure; |
-import org.chromium.chrome.test.ChromeActivityTestRule; |
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
+import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
import java.io.BufferedReader; |
import java.io.IOException; |
@@ -30,33 +22,29 @@ |
/** |
* Test to make sure browser and renderer are seperated process. |
*/ |
-@RunWith(ChromeJUnit4ClassRunner.class) |
-@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG}) |
-public class ProcessIsolationTest { |
- @Rule |
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule = |
- new ChromeActivityTestRule<>(ChromeActivity.class); |
+public class ProcessIsolationTest extends ChromeActivityTestCaseBase<ChromeActivity> { |
+ public ProcessIsolationTest() { |
+ super(ChromeActivity.class); |
+ } |
/** |
* Verifies that process isolation works, i.e., that the browser and |
* renderer processes use different user IDs. |
* @throws InterruptedException |
*/ |
- @Test |
@MediumTest |
@DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/517611") |
@Feature({"Browser", "Security"}) |
@RetryOnFailure |
public void testProcessIsolationForRenderers() throws InterruptedException { |
- int tabsCount = mActivityTestRule.getActivity().getCurrentTabModel().getCount(); |
+ int tabsCount = getActivity().getCurrentTabModel().getCount(); |
// The ActivityManager can be used to retrieve the current processes, but the reported UID |
// in the RunningAppProcessInfo for isolated processes is the same as the parent process |
// (see b/7724486, closed as "Working as intended"). |
// So we have to resort to parsing the ps output. |
String packageName = BuildInfo.getPackageName(); |
- Assert.assertFalse("Failed to retrieve package name for current version of Chrome.", |
- TextUtils.isEmpty(packageName)); |
+ assertFalse("Failed to retrieve package name for current version of Chrome.", |
+ TextUtils.isEmpty(packageName)); |
ArrayList<String> uids = new ArrayList<String>(); |
BufferedReader reader = null; |
@@ -67,7 +55,7 @@ |
Process psProcess = Runtime.getRuntime().exec("ps"); |
reader = new BufferedReader(new InputStreamReader(psProcess.getInputStream())); |
String line = reader.readLine(); |
- Assert.assertNotNull(line); |
+ assertNotNull(line); |
final String[] lineSections = line.split("\\s+"); |
int pidIndex = -1; |
for (int index = 0; index < lineSections.length; index++) { |
@@ -76,13 +64,13 @@ |
break; |
} |
} |
- Assert.assertNotSame(-1, pidIndex); |
+ assertNotSame(-1, pidIndex); |
while ((line = reader.readLine()) != null) { |
sb.append(line).append('\n'); |
if (line.indexOf(packageName) != -1) { |
final String uid = line.split("\\s+")[pidIndex]; |
- Assert.assertNotNull("Failed to retrieve UID from " + line, uid); |
+ assertNotNull("Failed to retrieve UID from " + line, uid); |
if (line.indexOf("sandboxed_process") != -1) { |
// Renderer process. |
uids.add(uid); |
@@ -103,7 +91,7 @@ |
} |
} |
} catch (IOException ioe) { |
- Assert.fail("Failed to read ps output."); |
+ fail("Failed to read ps output."); |
} finally { |
if (reader != null) { |
try { |
@@ -113,21 +101,22 @@ |
} |
} |
} |
- Assert.assertTrue( |
- "Browser process not found in ps output: \n" + sb.toString(), hasBrowserProcess); |
+ assertTrue("Browser process not found in ps output: \n" + sb.toString(), |
+ hasBrowserProcess); |
// We should have the same number of process as tabs count. Sometimes |
// there can be extra utility sandbox process so we check for greater than. |
- Assert.assertTrue("Renderer processes not found in ps output: \n" + sb.toString(), |
+ assertTrue( |
+ "Renderer processes not found in ps output: \n" + sb.toString(), |
rendererProcessesCount >= tabsCount); |
- Assert.assertEquals( |
- "Found at least two processes with the same UID in ps output: \n" + sb.toString(), |
+ assertEquals("Found at least two processes with the same UID in ps output: \n" |
+ + sb.toString(), |
uids.size(), new HashSet<String>(uids).size()); |
} |
- @Before |
- public void setUp() throws InterruptedException { |
- mActivityTestRule.startMainActivityFromLauncher(); |
+ @Override |
+ public void startMainActivity() throws InterruptedException { |
+ startMainActivityFromLauncher(); |
} |
} |