Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4099)

Unified Diff: chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java

Issue 11351002: Fix ChromiumTestShellTestBase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Nits Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java
diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java
index 8ad65529f6c21578d134624018a76b2eef4dc493..9defaf8dcee08b71fa4bc13c604f7604a98472dd 100644
--- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java
+++ b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java
@@ -20,6 +20,7 @@ import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
import org.chromium.chrome.browser.TabBase;
+import org.chromium.chrome.browser.TabObserver;
import org.chromium.content.browser.LoadUrlParams;
/**
@@ -42,6 +43,7 @@ public class TestShellToolbar extends LinearLayout {
private ClipDrawable mProgressDrawable;
private TabBase mTab;
+ private TabObserver mTabObserver = new TabObserverImpl();
/**
* @param context The Context the view is running in.
@@ -56,25 +58,17 @@ public class TestShellToolbar extends LinearLayout {
* @param tab The TabBase that should be represented.
*/
public void showTab(TabBase tab) {
+ if (mTab != null) mTab.removeObserver(mTabObserver);
mTab = tab;
+ mTab.addObserver(mTabObserver);
mUrlTextView.setText(mTab.getContentView().getUrl());
}
- /**
- * To be called when the URL of the represented {@link TabBase} updates.
- *
- * @param url The new URL of the currently represented {@link TabBase}.
- */
- public void onUpdateUrl(String url) {
+ private void onUpdateUrl(String url) {
mUrlTextView.setText(url);
}
- /**
- * To be called when the load progress of the represented {@link TabBase} updates.
- *
- * @param progress The current load progress. Should be a number between 0 and 100.
- */
- public void onLoadProgressChanged(int progress) {
+ private void onLoadProgressChanged(int progress) {
removeCallbacks(mClearProgressRunnable);
mProgressDrawable.setLevel((int) (100.0 * progress));
if (progress == 100) postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS);
@@ -147,4 +141,16 @@ public class TestShellToolbar extends LinearLayout {
imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
}
}
+
+ private class TabObserverImpl implements TabObserver {
+ @Override
+ public void onLoadProgressChanged(TabBase tab, int progress) {
+ if (tab == mTab) TestShellToolbar.this.onLoadProgressChanged(progress);
+ }
+
+ @Override
+ public void onUpdateUrl(TabBase tab, String url) {
+ if (tab == mTab) TestShellToolbar.this.onUpdateUrl(url);
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698