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

Unified Diff: chrome/browser/extensions/platform_app_browsertest.cc

Issue 10539060: Make platform app context menu browser tests more resilient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/platform_app_browsertest.cc
diff --git a/chrome/browser/extensions/platform_app_browsertest.cc b/chrome/browser/extensions/platform_app_browsertest.cc
index bf9df1c2edb4dc52dc0399ee3fe9891b051929bd..738b6f19cd8d5407b7825776fddf57b66705d47b 100644
--- a/chrome/browser/extensions/platform_app_browsertest.cc
+++ b/chrome/browser/extensions/platform_app_browsertest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/automation/automation_util.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
@@ -22,6 +23,10 @@ class PlatformAppContextMenu : public RenderViewContextMenu {
const content::ContextMenuParams& params)
: RenderViewContextMenu(web_contents, params) {}
+ bool HasCommandWithId(int command_id) {
+ return menu_model_.GetIndexOfCommandId(command_id) != -1;
+ }
+
protected:
// These two functions implement pure virtual methods of
// RenderViewContextMenu.
@@ -55,10 +60,10 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, EmptyContextMenu) {
PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents,
params);
menu->Init();
- // TODO(benwells): Remove the constant below. Instead of checking the
- // number of menu items check certain item's absense and presence.
- // 3 including separator
- ASSERT_EQ(3, menu->menu_model().GetItemCount());
+ ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
+ ASSERT_TRUE(menu->HasCommandWithId(IDC_RELOAD));
+ ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
+ ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) {
@@ -78,9 +83,11 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, AppWithContextMenu) {
PlatformAppContextMenu* menu = new PlatformAppContextMenu(web_contents,
params);
menu->Init();
- // TODO(benwells): Remove the constant below. Instead of checking the
- // number of menu items check certain item's absense and presence.
- ASSERT_EQ(4, menu->menu_model().GetItemCount());
+ ASSERT_TRUE(menu->HasCommandWithId(IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST));
+ ASSERT_TRUE(menu->HasCommandWithId(IDC_CONTENT_CONTEXT_INSPECTELEMENT));
+ ASSERT_TRUE(menu->HasCommandWithId(IDC_RELOAD));
+ ASSERT_FALSE(menu->HasCommandWithId(IDC_BACK));
+ ASSERT_FALSE(menu->HasCommandWithId(IDC_SAVE_PAGE));
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DisallowNavigation) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698