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

Side by Side Diff: chrome/browser/extensions/api/extension_action/page_as_browser_action_apitest.cc

Issue 48853005: Remove ExtensionToolbarModel from ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compile after rebase 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 6 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
7 #include "chrome/browser/extensions/browser_action_test_util.h" 7 #include "chrome/browser/extensions/browser_action_test_util.h"
8 #include "chrome/browser/extensions/extension_action.h" 8 #include "chrome/browser/extensions/extension_action.h"
9 #include "chrome/browser/extensions/extension_action_icon_factory.h" 9 #include "chrome/browser/extensions/extension_action_icon_factory.h"
10 #include "chrome/browser/extensions/extension_action_manager.h" 10 #include "chrome/browser/extensions/extension_action_manager.h"
11 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
12 #include "chrome/browser/extensions/extension_prefs.h" 12 #include "chrome/browser/extensions/extension_prefs.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_system.h" 14 #include "chrome/browser/extensions/extension_system.h"
15 #include "chrome/browser/extensions/extension_tab_util.h" 15 #include "chrome/browser/extensions/extension_tab_util.h"
16 #include "chrome/browser/extensions/extension_toolbar_model.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/omnibox/location_bar.h" 20 #include "chrome/browser/ui/omnibox/location_bar.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
23 #include "chrome/test/base/ui_test_utils.h" 24 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
25 26
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 int tab_id = ExtensionTabUtil::GetTabId( 83 int tab_id = ExtensionTabUtil::GetTabId(
83 browser()->tab_strip_model()->GetActiveWebContents()); 84 browser()->tab_strip_model()->GetActiveWebContents());
84 ExtensionAction* action = 85 ExtensionAction* action =
85 extension_action_manager()->GetBrowserAction(*extension); 86 extension_action_manager()->GetBrowserAction(*extension);
86 ASSERT_TRUE(action); 87 ASSERT_TRUE(action);
87 EXPECT_EQ("Modified", action->GetTitle(tab_id)); 88 EXPECT_EQ("Modified", action->GetTitle(tab_id));
88 89
89 { 90 {
90 // Simulate the page action being clicked. 91 // Simulate the page action being clicked.
91 ResultCatcher catcher; 92 ResultCatcher catcher;
92 ExtensionService* service = extensions::ExtensionSystem::Get( 93 ExtensionToolbarModel::Get(browser()->profile())->ExecuteBrowserAction(
93 browser()->profile())->extension_service();
94 service->toolbar_model()->ExecuteBrowserAction(
95 extension, browser(), NULL, true); 94 extension, browser(), NULL, true);
96 EXPECT_TRUE(catcher.GetNextResult()); 95 EXPECT_TRUE(catcher.GetNextResult());
97 } 96 }
98 97
99 { 98 {
100 // Tell the extension to update the page action state again. 99 // Tell the extension to update the page action state again.
101 ResultCatcher catcher; 100 ResultCatcher catcher;
102 ui_test_utils::NavigateToURL(browser(), 101 ui_test_utils::NavigateToURL(browser(),
103 GURL(extension->GetResourceURL("update2.html"))); 102 GURL(extension->GetResourceURL("update2.html")));
104 ASSERT_TRUE(catcher.GetNextResult()); 103 ASSERT_TRUE(catcher.GetNextResult());
(...skipping 22 matching lines...) Expand all
127 extension_action_manager()->GetBrowserAction(*extension); 126 extension_action_manager()->GetBrowserAction(*extension);
128 ASSERT_TRUE(page_action) 127 ASSERT_TRUE(page_action)
129 << "Page action test extension should have a page action."; 128 << "Page action test extension should have a page action.";
130 129
131 ASSERT_FALSE(page_action->HasPopup(tab_id)); 130 ASSERT_FALSE(page_action->HasPopup(tab_id));
132 131
133 // Simulate the page action being clicked. The resulting event should 132 // Simulate the page action being clicked. The resulting event should
134 // install a page action popup. 133 // install a page action popup.
135 { 134 {
136 ResultCatcher catcher; 135 ResultCatcher catcher;
137 ExtensionService* service = extensions::ExtensionSystem::Get( 136 ExtensionToolbarModel::Get(browser()->profile())->ExecuteBrowserAction(
138 browser()->profile())->extension_service();
139 service->toolbar_model()->ExecuteBrowserAction(
140 extension, browser(), NULL, true); 137 extension, browser(), NULL, true);
141 ASSERT_TRUE(catcher.GetNextResult()); 138 ASSERT_TRUE(catcher.GetNextResult());
142 } 139 }
143 140
144 ASSERT_TRUE(page_action->HasPopup(tab_id)) 141 ASSERT_TRUE(page_action->HasPopup(tab_id))
145 << "Clicking on the page action should have caused a popup to be added."; 142 << "Clicking on the page action should have caused a popup to be added.";
146 143
147 ASSERT_STREQ("/a_popup.html", 144 ASSERT_STREQ("/a_popup.html",
148 page_action->GetPopupUrl(tab_id).path().c_str()); 145 page_action->GetPopupUrl(tab_id).path().c_str());
149 146
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 ASSERT_TRUE(extension) << message_; 196 ASSERT_TRUE(extension) << message_;
200 197
201 ResultCatcher catcher; 198 ResultCatcher catcher;
202 ui_test_utils::NavigateToURL(browser(), 199 ui_test_utils::NavigateToURL(browser(),
203 GURL(extension->GetResourceURL("update.html"))); 200 GURL(extension->GetResourceURL("update.html")));
204 ASSERT_TRUE(catcher.GetNextResult()); 201 ASSERT_TRUE(catcher.GetNextResult());
205 } 202 }
206 203
207 } // namespace 204 } // namespace
208 } // namespace extensions 205 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698