Commit e16e7bf9 authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Commit Bot

Audit Profile usage in OfflinePageArchivePublisherBridgeTest

This CL explictly makes uses of Regular profile in the tests as
OfflinePageBridge is null for OTR profiles and it's already tested in
OfflinePageBridgeTest

Bug: 1060940
Change-Id: If215f7ea0beee9a1c5d7cdb20863a8df321dc6c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2494860Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820278}
parent 1900d71b
......@@ -53,17 +53,13 @@ public class OfflinePageArchivePublisherBridgeTest {
private OfflinePageBridge mOfflinePageBridge;
private EmbeddedTestServer mTestServer;
private String mTestPage;
private Profile mProfile;
private void initializeBridgeForProfile(final boolean incognitoProfile)
throws InterruptedException {
private void initializeBridgeForProfile() throws InterruptedException {
final Semaphore semaphore = new Semaphore(0);
PostTask.runOrPostTask(UiThreadTaskTraits.DEFAULT, () -> {
Profile profile = Profile.getLastUsedRegularProfile();
if (incognitoProfile) {
profile = profile.getOffTheRecordProfile();
}
// Ensure we start in an offline state.
mOfflinePageBridge = OfflinePageBridge.getForProfile(profile);
mOfflinePageBridge = OfflinePageBridge.getForProfile(mProfile);
if (mOfflinePageBridge == null || mOfflinePageBridge.isOfflinePageModelLoaded()) {
semaphore.release();
return;
......@@ -77,7 +73,6 @@ public class OfflinePageArchivePublisherBridgeTest {
});
});
Assert.assertTrue(semaphore.tryAcquire(TIMEOUT_MS, TimeUnit.MILLISECONDS));
if (!incognitoProfile) Assert.assertNotNull(mOfflinePageBridge);
}
@Before
......@@ -92,7 +87,10 @@ public class OfflinePageArchivePublisherBridgeTest {
}
});
initializeBridgeForProfile(false);
TestThreadUtils.runOnUiThreadBlocking(
() -> { mProfile = Profile.getLastUsedRegularProfile(); });
initializeBridgeForProfile();
Assert.assertNotNull(mOfflinePageBridge);
mTestServer = EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext());
mTestPage = mTestServer.getURL(TEST_PAGE);
......
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