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

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

Issue 10914244: Remove support for page_action.icons, and the legacy code surrounding it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: constants removed Created 8 years, 3 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 "chrome/browser/extensions/browser_event_router.h" 5 #include "chrome/browser/extensions/browser_event_router.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_tab_util.h" 8 #include "chrome/browser/extensions/extension_tab_util.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sessions/session_tab_helper.h" 10 #include "chrome/browser/sessions/session_tab_helper.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Simulate the page action being clicked. 173 // Simulate the page action being clicked.
174 { 174 {
175 ResultCatcher catcher; 175 ResultCatcher catcher;
176 int tab_id = 176 int tab_id =
177 ExtensionTabUtil::GetTabId(chrome::GetActiveWebContents(browser())); 177 ExtensionTabUtil::GetTabId(chrome::GetActiveWebContents(browser()));
178 ExtensionService* service = browser()->profile()->GetExtensionService(); 178 ExtensionService* service = browser()->profile()->GetExtensionService();
179 service->browser_event_router()->PageActionExecuted( 179 service->browser_event_router()->PageActionExecuted(
180 browser()->profile(), *extension->page_action(), tab_id, "", 1); 180 browser()->profile(), *extension->page_action(), tab_id, "", 1);
181 EXPECT_TRUE(catcher.GetNextResult()); 181 EXPECT_TRUE(catcher.GetNextResult());
182 } 182 }
183
184 // Set icon by its index.
185 {
186 int tab_id =
187 ExtensionTabUtil::GetTabId(chrome::GetActiveWebContents(browser()));
188
189 // Set some icon so we can verify it gets cleaned up by setIconIndex.
190 extension->page_action()->SetIcon(tab_id, CreateNonEmptyImage());
191 ASSERT_FALSE(
192 extension->page_action()->GetExplicitlySetIcon(tab_id).isNull());
193
194 // Currently, icon index should be set to 0.
195 ASSERT_EQ(0, extension->page_action()->GetIconIndex(tab_id));
196
197 ResultCatcher catcher;
198 ui_test_utils::NavigateToURL(browser(),
199 GURL(extension->GetResourceURL("set_icon_index.html")));
200 ASSERT_TRUE(catcher.GetNextResult());
201
202 // Check new value of icon index is as expected.
203 EXPECT_EQ(1, extension->page_action()->GetIconIndex(tab_id));
204 // Explicitly set icon should have been reset.
205 ASSERT_TRUE(
206 extension->page_action()->GetExplicitlySetIcon(tab_id).isNull());
207 }
208 } 183 }
209 184
210 // Tests popups in page actions. 185 // Tests popups in page actions.
211 // Flaky on the trybots. See http://crbug.com/96725. 186 // Flaky on the trybots. See http://crbug.com/96725.
212 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_ShowPageActionPopup) { 187 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_ShowPageActionPopup) {
213 ASSERT_TRUE(RunExtensionTest("page_action/popup")) << message_; 188 ASSERT_TRUE(RunExtensionTest("page_action/popup")) << message_;
214 const Extension* extension = GetSingleLoadedExtension(); 189 const Extension* extension = GetSingleLoadedExtension();
215 ASSERT_TRUE(extension) << message_; 190 ASSERT_TRUE(extension) << message_;
216 191
217 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 192 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
(...skipping 23 matching lines...) Expand all
241 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Getters) { 216 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Getters) {
242 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_; 217 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_;
243 const Extension* extension = GetSingleLoadedExtension(); 218 const Extension* extension = GetSingleLoadedExtension();
244 ASSERT_TRUE(extension) << message_; 219 ASSERT_TRUE(extension) << message_;
245 220
246 ResultCatcher catcher; 221 ResultCatcher catcher;
247 ui_test_utils::NavigateToURL(browser(), 222 ui_test_utils::NavigateToURL(browser(),
248 GURL(extension->GetResourceURL("update.html"))); 223 GURL(extension->GetResourceURL("update.html")));
249 ASSERT_TRUE(catcher.GetNextResult()); 224 ASSERT_TRUE(catcher.GetNextResult());
250 } 225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698