Commit 3b593dc0 authored by Side Yilmaz's avatar Side Yilmaz Committed by Commit Bot

Replace deprecated getLastUsedProfile function at tests for features

available in incognito.

Profile#getLastUsedProfile| is deprecated and replaced with
|Profile#getLastUsedRegularProfile|. This CL updates test classes for
the features that are available in incognito mode, or are persistent in
incognito mode.

Note: This change is only code clean-up, does not change any behaviour.

Bug: 1041781
Change-Id: Ia6d239d838d1cdde3799fe5864f753eb5948ceaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2115514
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753960}
parent ff4ed042
......@@ -57,8 +57,9 @@ public class NavigationPopupTest {
@Before
public void setUp() throws Exception {
mActivityTestRule.startMainActivityOnBlankPage();
// TODO (https://crbug.com/1063807): Add incognito mode tests.
TestThreadUtils.runOnUiThreadBlocking(
(Runnable) () -> mProfile = Profile.getLastUsedProfile());
(Runnable) () -> mProfile = Profile.getLastUsedRegularProfile());
}
// Exists solely to expose protected methods to this test.
......
......@@ -231,7 +231,8 @@ public final class PeriodicBackgroundSyncTest {
private void resetEngagementForUrl(final String url, final double engagement) {
TestThreadUtils.runOnUiThreadBlocking(() -> {
SiteEngagementService.getForProfile(Profile.getLastUsedProfile())
// TODO (https://crbug.com/1063807): Add incognito mode tests.
SiteEngagementService.getForProfile(Profile.getLastUsedRegularProfile())
.resetBaseScoreForUrl(url, engagement);
});
}
......
......@@ -211,7 +211,8 @@ public class AppBannerManagerTest {
private void resetEngagementForUrl(final String url, final double engagement) {
ThreadUtils.runOnUiThreadBlocking(() -> {
SiteEngagementService.getForProfile(Profile.getLastUsedProfile())
// TODO (https://crbug.com/1063807): Add incognito mode tests.
SiteEngagementService.getForProfile(Profile.getLastUsedRegularProfile())
.resetBaseScoreForUrl(url, engagement);
});
}
......
......@@ -321,9 +321,10 @@ public class TrustedCdnPublisherUrlTest {
runTrustedCdnPublisherUrlTest(
publisherUrl, "com.example.test", "example.com", R.drawable.omnibox_https_valid);
// TODO (https://crbug.com/1063807): Add incognito mode tests.
OfflinePageBridge offlinePageBridge =
TestThreadUtils.runOnUiThreadBlockingNoException(() -> {
Profile profile = Profile.getLastUsedProfile();
Profile profile = Profile.getLastUsedRegularProfile();
return OfflinePageBridge.getForProfile(profile);
});
......
......@@ -47,8 +47,9 @@ public class DistilledPagePrefsTest {
private void getDistilledPagePrefs() {
TestThreadUtils.runOnUiThreadBlocking(() -> {
// TODO (https://crbug.com/1063807): Add incognito mode tests.
DomDistillerService domDistillerService =
DomDistillerServiceFactory.getForProfile(Profile.getLastUsedProfile());
DomDistillerServiceFactory.getForProfile(Profile.getLastUsedRegularProfile());
mDistilledPagePrefs = domDistillerService.getDistilledPagePrefs();
});
}
......
......@@ -154,8 +154,9 @@ public class ConnectivityCheckerTest {
if (useSystemStack) {
ConnectivityChecker.checkConnectivitySystemNetworkStack(url, timeoutMs, callback);
} else {
// TODO (https://crbug.com/1063807): Add incognito mode tests.
ConnectivityChecker.checkConnectivityChromeNetworkStack(
Profile.getLastUsedProfile(), url, timeoutMs, callback);
Profile.getLastUsedRegularProfile(), url, timeoutMs, callback);
}
});
......
......@@ -58,7 +58,8 @@ public class ConnectivityTaskTest {
ConnectivityChecker.overrideUrlsForTest(
mConnectivityCheckerTestRule.getGenerated204Url(),
mConnectivityCheckerTestRule.getGenerated404Url());
return ConnectivityTask.create(Profile.getLastUsedProfile(), TIMEOUT_MS,
// TODO (https://crbug.com/1063807): Add incognito mode tests.
return ConnectivityTask.create(Profile.getLastUsedRegularProfile(), TIMEOUT_MS,
null);
}
});
......@@ -120,7 +121,8 @@ public class ConnectivityTaskTest {
ConnectivityChecker.overrideUrlsForTest(
mConnectivityCheckerTestRule.getGenerated204Url(),
mConnectivityCheckerTestRule.getGenerated404Url());
ConnectivityTask.create(Profile.getLastUsedProfile(), TIMEOUT_MS, callback);
// TODO (https://crbug.com/1063807): Add incognito mode tests.
ConnectivityTask.create(Profile.getLastUsedRegularProfile(), TIMEOUT_MS, callback);
});
if (!semaphore.tryAcquire(TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
Assert.fail("Failed to acquire semaphore.");
......@@ -150,7 +152,8 @@ public class ConnectivityTaskTest {
ConnectivityChecker.overrideUrlsForTest(
mConnectivityCheckerTestRule.getGenerated204Url(),
mConnectivityCheckerTestRule.getGeneratedSlowUrl());
ConnectivityTask.create(Profile.getLastUsedProfile(), checkTimeoutMs, callback);
// TODO (https://crbug.com/1063807): Add incognito mode tests.
ConnectivityTask.create(Profile.getLastUsedRegularProfile(), checkTimeoutMs, callback);
});
if (!semaphore.tryAcquire(TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
Assert.fail("Failed to acquire semaphore.");
......@@ -176,7 +179,8 @@ public class ConnectivityTaskTest {
ConnectivityChecker.overrideUrlsForTest(
mConnectivityCheckerTestRule.getGenerated204Url(),
mConnectivityCheckerTestRule.getGeneratedSlowUrl());
return ConnectivityTask.create(Profile.getLastUsedProfile(), TIMEOUT_MS,
// TODO (https://crbug.com/1063807): Add incognito mode tests.
return ConnectivityTask.create(Profile.getLastUsedRegularProfile(), TIMEOUT_MS,
null);
}
});
......
......@@ -115,7 +115,8 @@ public class NotificationPlatformBridgeTest {
return TestThreadUtils.runOnUiThreadBlocking(new Callable<Double>() {
@Override
public Double call() {
return SiteEngagementService.getForProfile(Profile.getLastUsedProfile())
// TODO (https://crbug.com/1063807): Add incognito mode tests.
return SiteEngagementService.getForProfile(Profile.getLastUsedRegularProfile())
.getScore(mPermissionTestRule.getOrigin());
}
});
......
......@@ -62,7 +62,8 @@ public class ExternalPrerenderHandlerTest {
final Callable<Profile> profileCallable = new Callable<Profile>() {
@Override
public Profile call() {
return Profile.getLastUsedProfile();
// TODO (https://crbug.com/1063807): Add incognito mode tests.
return Profile.getLastUsedRegularProfile();
}
};
mProfile = TestThreadUtils.runOnUiThreadBlocking(profileCallable);
......
......@@ -332,7 +332,8 @@ public class TileGridLayoutTest {
ChromeActivity activity = mActivityTestRule.getActivity();
Profile profile = Profile.getLastUsedProfile();
// TODO (https://crbug.com/1063807): Add incognito mode tests.
Profile profile = Profile.getLastUsedRegularProfile();
SuggestionsUiDelegate uiDelegate = new SuggestionsUiDelegateImpl(
mSuggestionsDeps.getFactory().createSuggestionSource(null),
mSuggestionsDeps.getFactory().createEventReporter(), null, profile, null,
......
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