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

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

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | 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/browser_action_test_util.h" 6 #include "chrome/browser/extensions/browser_action_test_util.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_prefs.h" 9 #include "chrome/browser/extensions/extension_prefs.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_tab_util.h" 11 #include "chrome/browser/extensions/extension_tab_util.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sessions/restore_tab_helper.h" 13 #include "chrome/browser/sessions/restore_tab_helper.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/omnibox/location_bar.h" 17 #include "chrome/browser/ui/omnibox/location_bar.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/extensions/extension.h" 20 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_action.h" 21 #include "chrome/common/extensions/extension_action.h"
21 #include "chrome/test/base/ui_test_utils.h" 22 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 24
24 // These are a mash-up of the tests from from page_actions_apitest.cc and 25 // These are a mash-up of the tests from from page_actions_apitest.cc and
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 66
66 { 67 {
67 // Tell the extension to update the page action state. 68 // Tell the extension to update the page action state.
68 ResultCatcher catcher; 69 ResultCatcher catcher;
69 ui_test_utils::NavigateToURL(browser(), 70 ui_test_utils::NavigateToURL(browser(),
70 GURL(extension->GetResourceURL("update.html"))); 71 GURL(extension->GetResourceURL("update.html")));
71 ASSERT_TRUE(catcher.GetNextResult()); 72 ASSERT_TRUE(catcher.GetNextResult());
72 } 73 }
73 74
74 // Test that we received the changes. 75 // Test that we received the changes.
75 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetActiveWebContents()); 76 int tab_id = ExtensionTabUtil::GetTabId(
77 chrome::GetActiveWebContents(browser()));
76 ExtensionAction* action = extension->browser_action(); 78 ExtensionAction* action = extension->browser_action();
77 ASSERT_TRUE(action); 79 ASSERT_TRUE(action);
78 EXPECT_EQ("Modified", action->GetTitle(tab_id)); 80 EXPECT_EQ("Modified", action->GetTitle(tab_id));
79 81
80 { 82 {
81 // Simulate the page action being clicked. 83 // Simulate the page action being clicked.
82 ResultCatcher catcher; 84 ResultCatcher catcher;
83 ExtensionService* service = browser()->profile()->GetExtensionService(); 85 ExtensionService* service = browser()->profile()->GetExtensionService();
84 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL); 86 service->toolbar_model()->ExecuteBrowserAction(extension, browser(), NULL);
85 EXPECT_TRUE(catcher.GetNextResult()); 87 EXPECT_TRUE(catcher.GetNextResult());
(...skipping 11 matching lines...) Expand all
97 EXPECT_FALSE(action->GetIcon(tab_id).isNull()); 99 EXPECT_FALSE(action->GetIcon(tab_id).isNull());
98 } 100 }
99 101
100 // Test that calling chrome.pageAction.setPopup() can enable a popup. 102 // Test that calling chrome.pageAction.setPopup() can enable a popup.
101 IN_PROC_BROWSER_TEST_F(PageAsBrowserActionApiTest, AddPopup) { 103 IN_PROC_BROWSER_TEST_F(PageAsBrowserActionApiTest, AddPopup) {
102 // Load the extension, which has no default popup. 104 // Load the extension, which has no default popup.
103 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_; 105 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_;
104 const Extension* extension = GetSingleLoadedExtension(); 106 const Extension* extension = GetSingleLoadedExtension();
105 ASSERT_TRUE(extension) << message_; 107 ASSERT_TRUE(extension) << message_;
106 108
107 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetActiveWebContents()); 109 int tab_id = ExtensionTabUtil::GetTabId(
110 chrome::GetActiveWebContents(browser()));
108 111
109 ExtensionAction* page_action = extension->browser_action(); 112 ExtensionAction* page_action = extension->browser_action();
110 ASSERT_TRUE(page_action) 113 ASSERT_TRUE(page_action)
111 << "Page action test extension should have a page action."; 114 << "Page action test extension should have a page action.";
112 115
113 ASSERT_FALSE(page_action->HasPopup(tab_id)); 116 ASSERT_FALSE(page_action->HasPopup(tab_id));
114 117
115 // Simulate the page action being clicked. The resulting event should 118 // Simulate the page action being clicked. The resulting event should
116 // install a page action popup. 119 // install a page action popup.
117 { 120 {
(...skipping 24 matching lines...) Expand all
142 page_action->GetPopupUrl(tab_id).path().c_str()); 145 page_action->GetPopupUrl(tab_id).path().c_str());
143 } 146 }
144 147
145 // Test that calling chrome.pageAction.setPopup() can remove a popup. 148 // Test that calling chrome.pageAction.setPopup() can remove a popup.
146 IN_PROC_BROWSER_TEST_F(PageAsBrowserActionApiTest, RemovePopup) { 149 IN_PROC_BROWSER_TEST_F(PageAsBrowserActionApiTest, RemovePopup) {
147 // Load the extension, which has a page action with a default popup. 150 // Load the extension, which has a page action with a default popup.
148 ASSERT_TRUE(RunExtensionTest("page_action/remove_popup")) << message_; 151 ASSERT_TRUE(RunExtensionTest("page_action/remove_popup")) << message_;
149 const Extension* extension = GetSingleLoadedExtension(); 152 const Extension* extension = GetSingleLoadedExtension();
150 ASSERT_TRUE(extension) << message_; 153 ASSERT_TRUE(extension) << message_;
151 154
152 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetActiveWebContents()); 155 int tab_id = ExtensionTabUtil::GetTabId(
156 chrome::GetActiveWebContents(browser()));
153 157
154 ExtensionAction* page_action = extension->browser_action(); 158 ExtensionAction* page_action = extension->browser_action();
155 ASSERT_TRUE(page_action) 159 ASSERT_TRUE(page_action)
156 << "Page action test extension should have a page action."; 160 << "Page action test extension should have a page action.";
157 161
158 ASSERT_TRUE(page_action->HasPopup(tab_id)) 162 ASSERT_TRUE(page_action->HasPopup(tab_id))
159 << "Expect a page action popup before the test removes it."; 163 << "Expect a page action popup before the test removes it.";
160 164
161 // Load a page which removes the popup using chrome.pageAction.setPopup(). 165 // Load a page which removes the popup using chrome.pageAction.setPopup().
162 { 166 {
(...skipping 13 matching lines...) Expand all
176 const Extension* extension = GetSingleLoadedExtension(); 180 const Extension* extension = GetSingleLoadedExtension();
177 ASSERT_TRUE(extension) << message_; 181 ASSERT_TRUE(extension) << message_;
178 182
179 ResultCatcher catcher; 183 ResultCatcher catcher;
180 ui_test_utils::NavigateToURL(browser(), 184 ui_test_utils::NavigateToURL(browser(),
181 GURL(extension->GetResourceURL("update.html"))); 185 GURL(extension->GetResourceURL("update.html")));
182 ASSERT_TRUE(catcher.GetNextResult()); 186 ASSERT_TRUE(catcher.GetNextResult());
183 } 187 }
184 188
185 } 189 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698