This source file includes following definitions.
- Feature
- testBaseStartup
- Feature
- testChromeWelcomePageLoads
- Feature
- testCompositorInit
package org.chromium.chrome.shell;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.ContentViewRenderView;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
public class ChromeShellUrlTest extends ChromeShellTestBase {
private static final String URL = "data:text";
@SmallTest
@Feature({"Main"})
public void testBaseStartup() throws InterruptedException {
ChromeShellActivity activity = launchChromeShellWithUrl(URL);
waitForActiveShellToBeDoneLoading();
assertNotNull(activity);
}
@SmallTest
@Feature({"Main"})
public void testChromeWelcomePageLoads() throws InterruptedException {
String welcomeUrl = "chrome://welcome/";
final ChromeShellActivity activity = launchChromeShellWithUrl(welcomeUrl);
waitForActiveShellToBeDoneLoading();
assertNotNull(activity);
final AtomicReference<ContentView> contentView = new AtomicReference<ContentView>();
final AtomicReference<ContentViewCore> contentViewCore =
new AtomicReference<ContentViewCore>();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
ContentView activeContentView = activity.getActiveContentView();
contentView.set(activeContentView);
if (activeContentView != null) {
contentViewCore.set(activeContentView.getContentViewCore());
}
}
});
assertNotNull(contentView.get());
assertNotNull(contentViewCore.get());
final AtomicBoolean isShowingInterstitialPage = new AtomicBoolean();
final AtomicReference<String> url = new AtomicReference<String>();
final AtomicReference<String> title = new AtomicReference<String>();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
isShowingInterstitialPage.set(contentViewCore.get().isShowingInterstitialPage());
url.set(contentViewCore.get().getUrl());
title.set(contentViewCore.get().getTitle());
}
});
assertFalse("Showed interstitial page instead of welcome page",
isShowingInterstitialPage.get());
assertNotNull("URL was null", url.get());
assertTrue("URL did not contain: " + welcomeUrl + ". Was: " + url.get(),
url.get().contains(welcomeUrl));
assertNotNull("Title was null", title.get());
assertFalse("Title should not contain: " + welcomeUrl + ". Was: " + title.get(),
title.get().toLowerCase(Locale.US).contains(welcomeUrl));
}
@SmallTest
@Feature({"Main"})
public void testCompositorInit() throws InterruptedException {
final ChromeShellActivity activity = launchChromeShellWithUrl(URL);
waitForActiveShellToBeDoneLoading();
try {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
ContentViewRenderView contentViewRenderView =
new ContentViewRenderView(getInstrumentation().getTargetContext(),
activity.getWindowAndroid());
contentViewRenderView.setCurrentContentView(activity.getActiveContentView());
}
});
} catch (Throwable e) {
fail("Could not create a ContentViewRenderView: " + e);
}
}