summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authordtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-29 14:18:40 +0000
committerdtrainor@chromium.org <dtrainor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-29 14:18:40 +0000
commit6a5fcf6ff8807641df7f0b54bcb68442fb911ad8 (patch)
tree812a9fe7fdc68fba10cbae0a70b2815abdd2e295 /content/shell
parent16e7800dbfea61164a399d380c430d864de00d52 (diff)
downloadchromium_src-6a5fcf6ff8807641df7f0b54bcb68442fb911ad8.zip
chromium_src-6a5fcf6ff8807641df7f0b54bcb68442fb911ad8.tar.gz
chromium_src-6a5fcf6ff8807641df7f0b54bcb68442fb911ad8.tar.bz2
Fixed ContentViewTestBase#setUpContentView
- Added support for waiting for the ContentShell's active shell to completely load before continuing with teh rest of setUpContentView. - Made setUpContentView do a final reload to a blank file after the set up is complete and the JS is injected. BUG=http://crbug.com/152735 Review URL: https://chromiumcodereview.appspot.com/11021002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/android/java/src/org/chromium/content_shell/Shell.java15
-rw-r--r--content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java49
-rw-r--r--content/shell/shell_android.cc2
3 files changed, 66 insertions, 0 deletions
diff --git a/content/shell/android/java/src/org/chromium/content_shell/Shell.java b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
index 21ce108..ff5f138 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/Shell.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
@@ -51,6 +51,8 @@ public class Shell extends LinearLayout {
private View mSurfaceView;
private NativeWindow mWindow;
+ private boolean mLoading = false;
+
/**
* Constructor for inflating via XML.
*/
@@ -76,6 +78,13 @@ public class Shell extends LinearLayout {
mWindow = window;
}
+ /**
+ * @return Whether or not the Shell is loading content.
+ */
+ public boolean isLoading() {
+ return mLoading;
+ }
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
@@ -174,6 +183,12 @@ public class Shell extends LinearLayout {
if (progress == 1.0) postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS);
}
+ @SuppressWarnings("unused")
+ @CalledByNative
+ private void setIsLoading(boolean loading) {
+ mLoading = loading;
+ }
+
/**
* Initializes the ContentView based on the native tab contents pointer passed in.
* @param nativeTabContents The pointer to the native tab contents object.
diff --git a/content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java b/content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java
index 7dd3061..1c633db 100644
--- a/content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java
+++ b/content/shell/android/javatests/src/org/chromium/content_shell/ContentShellTestBase.java
@@ -8,6 +8,13 @@ import android.content.ComponentName;
import android.content.Intent;
import android.net.Uri;
import android.test.ActivityInstrumentationTestCase2;
+import android.text.TextUtils;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.chromium.content.browser.test.util.Criteria;
+import org.chromium.content.browser.test.util.CriteriaHelper;
/**
* Base test class for all ContentShell based tests.
@@ -31,4 +38,46 @@ public class ContentShellTestBase extends ActivityInstrumentationTestCase2<Conte
setActivityIntent(intent);
return getActivity();
}
+
+ /**
+ * Waits for the Active shell to finish loading. This times out after three seconds,
+ * so it shouldn't be used for long loading pages. Instead it should be used more for
+ * test initialization. The proper way to wait is to use a TestCallbackHelperContainer
+ * after the initial load is completed.
+ * @return Whether or not the Shell was actually finished loading.
+ * @throws Exception
+ */
+ protected boolean waitForActiveShellToBeDoneLoading() throws Exception {
+ final ContentShellActivity activity = getActivity();
+
+ // Wait for the Content Shell to be initialized.
+ return CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ try {
+ final AtomicBoolean isLoaded = new AtomicBoolean(false);
+ runTestOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = activity.getActiveShell();
+ if (shell != null) {
+ // There are two cases here that need to be accounted for.
+ // The first is that we've just created a Shell and it isn't
+ // loading because it has no URL set yet. The second is that
+ // we've set a URL and it actually is loading.
+ isLoaded.set(!shell.isLoading()
+ && !TextUtils.isEmpty(shell.getContentView().getUrl()));
+ } else {
+ isLoaded.set(false);
+ }
+ }
+ });
+
+ return isLoaded.get();
+ } catch (Throwable e) {
+ return false;
+ }
+ }
+ });
+ }
}
diff --git a/content/shell/shell_android.cc b/content/shell/shell_android.cc
index 393d9a1..ddd1722 100644
--- a/content/shell/shell_android.cc
+++ b/content/shell/shell_android.cc
@@ -40,6 +40,8 @@ void Shell::PlatformSetAddressBarURL(const GURL& url) {
}
void Shell::PlatformSetIsLoading(bool loading) {
+ JNIEnv* env = AttachCurrentThread();
+ Java_Shell_setIsLoading(env, java_object_.obj(), loading);
}
void Shell::PlatformCreateWindow(int width, int height) {