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

Side by Side Diff: chrome/browser/extensions/browser_action_apitest.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
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/extensions/browser_action_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_apitest.h"
8 #include "chrome/browser/extensions/extension_browser_event_router.h"
9 #include "chrome/browser/extensions/extension_tabs_module.h"
10 #include "chrome/browser/extensions/extensions_service.h"
11 #include "chrome/browser/profile.h"
12 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/browser/views/browser_actions_container.h"
14 #include "chrome/browser/views/toolbar_view.h"
15 #include "chrome/common/extensions/extension_action.h"
16 #include "chrome/test/ui_test_utils.h"
17
18 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserAction) {
19 StartHTTPServer();
20 ASSERT_TRUE(RunExtensionTest("browser_action")) << message_;
21
22 // Test that there is a browser action in the toolbar.
23 BrowserActionsContainer* browser_actions =
24 browser()->window()->GetBrowserWindowTesting()->GetToolbarView()->
25 browser_actions();
26 ASSERT_EQ(1, browser_actions->num_browser_actions());
27
28 // Tell the extension to update the browser action state.
29 TestResultCatcher catcher;
30 ExtensionsService* service = browser()->profile()->GetExtensionsService();
31 Extension* extension = service->extensions()->at(0);
32 ui_test_utils::NavigateToURL(browser(),
33 GURL(extension->GetResourceURL("update.html")));
34 ASSERT_TRUE(catcher.GetNextResult());
35
36 // Test that we received the changes.
37 ExtensionActionState* action_state = extension->browser_action_state();
38 ASSERT_EQ("Modified", action_state->title());
39 ASSERT_EQ(1, action_state->icon_index());
40 ASSERT_EQ("badge", action_state->badge_text());
41 ASSERT_EQ(SkColorSetARGB(255, 255, 255, 255),
42 action_state->badge_background_color());
43
44 // Simulate the browser action being clicked.
45 ui_test_utils::NavigateToURL(browser(),
46 GURL("http://localhost:1337/files/extensions/test_file.txt"));
47
48 ExtensionAction* browser_action = service->GetBrowserActions(false)[0];
49 int window_id = ExtensionTabUtil::GetWindowId(browser());
50 ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
51 browser()->profile(), browser_action->extension_id(), browser());
52
53 // Verify the command worked.
54 TabContents* tab = browser()->GetSelectedTabContents();
55 bool result = false;
56 ui_test_utils::ExecuteJavaScriptAndExtractBool(
57 tab->render_view_host(), L"",
58 L"setInterval(function(){"
59 L" if(document.body.bgColor == 'red'){"
60 L" window.domAutomationController.send(true)}}, 100)",
61 &result);
62 ASSERT_TRUE(result);
63 }
64
65
66 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DynamicBrowserAction) {
67 ASSERT_TRUE(RunExtensionTest("browser_action_no_icon")) << message_;
68
69 // Test that there is a browser action in the toolbar.
70 BrowserActionsContainer* browser_actions =
71 browser()->window()->GetBrowserWindowTesting()->GetToolbarView()->
72 browser_actions();
73 ASSERT_EQ(1, browser_actions->num_browser_actions());
74
75 // Tell the extension to update the browser action state.
76 TestResultCatcher catcher;
77 ExtensionsService* service = browser()->profile()->GetExtensionsService();
78 Extension* extension = service->extensions()->at(0);
79 ui_test_utils::NavigateToURL(browser(),
80 GURL(extension->GetResourceURL("update.html")));
81 ASSERT_TRUE(catcher.GetNextResult());
82
83 // Test that we received the changes.
84 ExtensionActionState* action_state = extension->browser_action_state();
85 ASSERT_TRUE(action_state->icon());
86 }
OLDNEW
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/extensions/browser_action_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698