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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/TabBaseTabUtils.java

Issue 73173002: Add ContextMenu support upstream for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added tests, addressed comments Created 7 years, 1 month 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/javatests/src/org/chromium/chrome/browser/TabBaseTabUtils.java
diff --git a/chrome/android/testshell/javatests/src/org/chromium/chrome/testshell/TabShellTabUtils.java b/chrome/android/javatests/src/org/chromium/chrome/browser/TabBaseTabUtils.java
similarity index 63%
rename from chrome/android/testshell/javatests/src/org/chromium/chrome/testshell/TabShellTabUtils.java
rename to chrome/android/javatests/src/org/chromium/chrome/browser/TabBaseTabUtils.java
index 35d5df0620e9893f7a837d73172a21c7f663283b..35addbe3b37dac9d77057d033a6b0b3168cb8002 100644
--- a/chrome/android/testshell/javatests/src/org/chromium/chrome/testshell/TabShellTabUtils.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/TabBaseTabUtils.java
@@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.chromium.chrome.testshell;
+package org.chromium.chrome.browser;
+
+import android.view.ContextMenu;
import org.chromium.chrome.browser.EmptyTabObserver;
import org.chromium.chrome.browser.TabBase;
@@ -13,11 +15,13 @@ import org.chromium.content.browser.test.util.TestContentViewClient;
import org.chromium.content.browser.test.util.TestContentViewClientWrapper;
import org.chromium.content.browser.test.util.TestWebContentsObserver;
+import java.lang.ref.WeakReference;
+
/**
* A utility class that contains methods generic to all Tabs tests.
*/
-public class TabShellTabUtils {
- private static TestContentViewClient createTestContentViewClientForTab(TestShellTab tab) {
+public class TabBaseTabUtils {
+ private static TestContentViewClient createTestContentViewClientForTab(TabBase tab) {
ContentViewClient client = tab.getContentView().getContentViewClient();
if (client instanceof TestContentViewClient) return (TestContentViewClient) client;
@@ -28,31 +32,57 @@ public class TabShellTabUtils {
public static class TestCallbackHelperContainerForTab extends TestCallbackHelperContainer {
private final OnCloseTabHelper mOnCloseTabHelper;
- public TestCallbackHelperContainerForTab(TestShellTab tab) {
+ private final OnContextMenuShownHelper mOnContextMenuShownHelper;
+
+ public TestCallbackHelperContainerForTab(TabBase tab) {
super(createTestContentViewClientForTab(tab),
new TestWebContentsObserver(tab.getContentView().getContentViewCore()));
mOnCloseTabHelper = new OnCloseTabHelper();
+ mOnContextMenuShownHelper = new OnContextMenuShownHelper();
tab.addObserver(new EmptyTabObserver() {
@Override
public void onDestroyed(TabBase tab) {
mOnCloseTabHelper.notifyCalled();
}
+
+ @Override
+ public void onContextMenuShown(TabBase tab, ContextMenu menu) {
+ mOnContextMenuShownHelper.notifyCalled(menu);
+ }
});
}
public static class OnCloseTabHelper extends CallbackHelper {
}
+ public static class OnContextMenuShownHelper extends CallbackHelper {
+ private WeakReference<ContextMenu> mContextMenu;
+
+ public void notifyCalled(ContextMenu menu) {
+ mContextMenu = new WeakReference<ContextMenu>(menu);
+ notifyCalled();
+ }
+
+ public ContextMenu getContextMenu() {
+ System.out.println("weak reference: " + mContextMenu.get());
Ted C 2013/11/26 01:50:09 remove print out
David Trainor- moved to gerrit 2013/11/26 23:51:07 Done.
+ assert getCallCount() > 0;
+ return mContextMenu.get();
+ }
+ }
+
public OnCloseTabHelper getOnCloseTabHelper() {
return mOnCloseTabHelper;
}
+
+ public OnContextMenuShownHelper getOnContextMenuShownHelper() {
+ return mOnContextMenuShownHelper;
+ }
}
/**
* Creates, binds and returns a TestCallbackHelperContainer for a given Tab.
*/
- public static TestCallbackHelperContainerForTab getTestCallbackHelperContainer(
- final TestShellTab tab) {
+ public static TestCallbackHelperContainerForTab getTestCallbackHelperContainer(TabBase tab) {
return tab == null ? null : new TestCallbackHelperContainerForTab(tab);
}
}

Powered by Google App Engine
This is Rietveld 408576698