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

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

Issue 337035: Replace ExtensionAction with ExtensionAction2. (Closed)
Patch Set: Remove todo Created 11 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_browser_actions_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browser.h" 5 #include "chrome/browser/browser.h"
6 #include "chrome/browser/browser_window.h" 6 #include "chrome/browser/browser_window.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_browser_event_router.h" 8 #include "chrome/browser/extensions/extension_browser_event_router.h"
9 #include "chrome/browser/extensions/extension_tabs_module.h" 9 #include "chrome/browser/extensions/extension_tabs_module.h"
10 #include "chrome/browser/extensions/extensions_service.h" 10 #include "chrome/browser/extensions/extensions_service.h"
11 #include "chrome/browser/profile.h" 11 #include "chrome/browser/profile.h"
12 #include "chrome/browser/tab_contents/tab_contents.h" 12 #include "chrome/browser/tab_contents/tab_contents.h"
13 #include "chrome/browser/views/browser_actions_container.h" 13 #include "chrome/browser/views/browser_actions_container.h"
14 #include "chrome/browser/views/extensions/extension_popup.h" 14 #include "chrome/browser/views/extensions/extension_popup.h"
15 #include "chrome/browser/views/toolbar_view.h" 15 #include "chrome/browser/views/toolbar_view.h"
16 #include "chrome/common/extensions/extension_action2.h" 16 #include "chrome/common/extensions/extension_action.h"
17 #include "chrome/test/ui_test_utils.h" 17 #include "chrome/test/ui_test_utils.h"
18 18
19 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserAction) { 19 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserAction) {
20 StartHTTPServer(); 20 StartHTTPServer();
21 ASSERT_TRUE(RunExtensionTest("browser_action")) << message_; 21 ASSERT_TRUE(RunExtensionTest("browser_action")) << message_;
22 22
23 // Test that there is a browser action in the toolbar. 23 // Test that there is a browser action in the toolbar.
24 BrowserActionsContainer* browser_actions = 24 BrowserActionsContainer* browser_actions =
25 browser()->window()->GetBrowserWindowTesting()->GetToolbarView()-> 25 browser()->window()->GetBrowserWindowTesting()->GetToolbarView()->
26 browser_actions(); 26 browser_actions();
27 ASSERT_EQ(1, browser_actions->num_browser_actions()); 27 ASSERT_EQ(1, browser_actions->num_browser_actions());
28 28
29 // Tell the extension to update the browser action state. 29 // Tell the extension to update the browser action state.
30 ResultCatcher catcher; 30 ResultCatcher catcher;
31 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 31 ExtensionsService* service = browser()->profile()->GetExtensionsService();
32 Extension* extension = service->extensions()->at(0); 32 Extension* extension = service->extensions()->at(0);
33 ui_test_utils::NavigateToURL(browser(), 33 ui_test_utils::NavigateToURL(browser(),
34 GURL(extension->GetResourceURL("update.html"))); 34 GURL(extension->GetResourceURL("update.html")));
35 ASSERT_TRUE(catcher.GetNextResult()); 35 ASSERT_TRUE(catcher.GetNextResult());
36 36
37 // Test that we received the changes. 37 // Test that we received the changes.
38 ExtensionAction2* action = extension->browser_action(); 38 ExtensionAction* action = extension->browser_action();
39 ASSERT_EQ("Modified", action->GetTitle(ExtensionAction2::kDefaultTabId)); 39 ASSERT_EQ("Modified", action->GetTitle(ExtensionAction::kDefaultTabId));
40 ASSERT_EQ("badge", action->GetBadgeText(ExtensionAction2::kDefaultTabId)); 40 ASSERT_EQ("badge", action->GetBadgeText(ExtensionAction::kDefaultTabId));
41 ASSERT_EQ(SkColorSetARGB(255, 255, 255, 255), 41 ASSERT_EQ(SkColorSetARGB(255, 255, 255, 255),
42 action->GetBadgeBackgroundColor(ExtensionAction2::kDefaultTabId)); 42 action->GetBadgeBackgroundColor(ExtensionAction::kDefaultTabId));
43 43
44 // Simulate the browser action being clicked. 44 // Simulate the browser action being clicked.
45 ui_test_utils::NavigateToURL(browser(), 45 ui_test_utils::NavigateToURL(browser(),
46 GURL("http://localhost:1337/files/extensions/test_file.txt")); 46 GURL("http://localhost:1337/files/extensions/test_file.txt"));
47 47
48 int window_id = ExtensionTabUtil::GetWindowId(browser()); 48 int window_id = ExtensionTabUtil::GetWindowId(browser());
49 ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted( 49 ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted(
50 browser()->profile(), action->extension_id(), browser()); 50 browser()->profile(), action->extension_id(), browser());
51 51
52 // Verify the command worked. 52 // Verify the command worked.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // opened). 164 // opened).
165 browser_actions->TestExecuteBrowserAction(0); 165 browser_actions->TestExecuteBrowserAction(0);
166 EXPECT_TRUE(browser_actions->TestGetPopup() != NULL); 166 EXPECT_TRUE(browser_actions->TestGetPopup() != NULL);
167 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); 167 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message();
168 bounds = browser_actions->TestGetPopup()->view()->bounds(); 168 bounds = browser_actions->TestGetPopup()->view()->bounds();
169 EXPECT_EQ(200, bounds.width()); 169 EXPECT_EQ(200, bounds.width());
170 EXPECT_EQ(200, bounds.height()); 170 EXPECT_EQ(200, bounds.height());
171 browser_actions->HidePopup(); 171 browser_actions->HidePopup();
172 EXPECT_TRUE(browser_actions->TestGetPopup() == NULL); 172 EXPECT_TRUE(browser_actions->TestGetPopup() == NULL);
173 } 173 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_browser_actions_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698