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

Side by Side Diff: chrome/browser/extensions/browser_action_test.cc

Issue 276010: Remove the implicit wrench menu items for browser actions. (Closed)
Patch Set: Rebase Created 11 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/browser.h"
6 #include "chrome/browser/browser_window.h"
7 #include "chrome/browser/extensions/extension_browsertest.h"
8 #include "chrome/browser/extensions/extensions_service.h"
9 #include "chrome/browser/profile.h"
10 #include "chrome/browser/tab_contents/tab_contents.h"
11 #include "chrome/browser/views/browser_actions_container.h"
12 #include "chrome/browser/views/toolbar_view.h"
13 #include "chrome/common/extensions/extension_action.h"
14 #include "chrome/test/ui_test_utils.h"
15
16 #if defined(OS_LINUX)
17 #include "chrome/browser/gtk/view_id_util.h"
18 #endif
19
20 static void CheckButtonCount(Browser* browser, const int expected_count) {
21 #if defined(OS_WIN)
22 BrowserActionsContainer* browser_actions =
23 browser->window()->GetBrowserWindowTesting()->GetToolbarView()->
24 browser_actions();
25 int num_buttons = browser_actions->num_browser_actions();
26 #elif defined(OS_LINUX)
27 GtkWidget* widget = ViewIDUtil::GetWidget(
28 GTK_WIDGET(browser->window()->GetNativeHandle()),
29 VIEW_ID_BROWSER_ACTION_TOOLBAR);
30 ASSERT_TRUE(widget);
31 GList* children = gtk_container_get_children(GTK_CONTAINER(widget));
32 int num_buttons = g_list_length(children);
33 g_list_free(children);
34 #endif
35
36 EXPECT_EQ(expected_count, num_buttons);
37 }
38
39 static void TestAction(Browser* browser) {
40 // Navigate to a page we have permission to modify.
41 ui_test_utils::NavigateToURL(browser,
42 GURL("http://localhost:1337/files/extensions/test_file.txt"));
43
44 // Send the command. Note that this only works for non-popup actions, so
45 // we specify |false|.
46 ExtensionsService* service = browser->profile()->GetExtensionsService();
47 browser->ExecuteCommand(service->GetBrowserActions(false)[0]->command_id());
48
49 // Verify the command worked.
50 TabContents* tab = browser->GetSelectedTabContents();
51 bool result = false;
52 ui_test_utils::ExecuteJavaScriptAndExtractBool(
53 tab->render_view_host(), L"",
54 L"setInterval(function(){"
55 L" if(document.body.bgColor == 'red'){"
56 L" window.domAutomationController.send(true)}}, 100)",
57 &result);
58 ASSERT_TRUE(result);
59 }
60
61 // Crashes frequently on Linux. See http://crbug.com/24802.
62 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_BrowserAction) {
63 StartHTTPServer();
64
65 ASSERT_TRUE(LoadExtension(
66 test_data_dir_.AppendASCII("samples")
67 .AppendASCII("make_page_red")));
68
69 // Test that there is a browser action in the toolbar.
70 CheckButtonCount(browser(), 1);
71
72 TestAction(browser());
73 }
74
75 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, BrowserActionNoIcon) {
76 StartHTTPServer();
77
78 ASSERT_TRUE(LoadExtension(
79 test_data_dir_.AppendASCII("samples")
80 .AppendASCII("make_page_red_no_icon")));
81
82 // Test that there is a *not* a browser action in the toolbar.
83 CheckButtonCount(browser(), 0);
84
85 TestAction(browser());
86 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/browser_action_apitest.cc ('k') | chrome/browser/extensions/extension_apitest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698