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

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

Issue 10905005: Change browser/page action default icon defined in manifest to support hidpi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/restore_tab_helper.h" 10 #include "chrome/browser/sessions/restore_tab_helper.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_tabstrip.h" 12 #include "chrome/browser/ui/browser_tabstrip.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/omnibox/location_bar.h" 14 #include "chrome/browser/ui/omnibox/location_bar.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents.h"
16 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/extension_action.h" 17 #include "chrome/common/extensions/extension_action.h"
18 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "testing/gmock/include/gmock/gmock.h"
20 21
21 using extensions::Extension; 22 using extensions::Extension;
23 using ::testing::_;
24
25 namespace {
26
27 class MockActionIconFactory : public ExtensionAction::IconFactory {
28 public:
29 virtual ~MockActionIconFactory() {}
30
31 MOCK_METHOD2(GetIcon, gfx::ImageSkia(const ExtensionIconSet* icon_set,
32 ExtensionAction::Type type));
33 };
34
35 } // namespace
22 36
23 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) { 37 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageAction) {
24 ASSERT_TRUE(test_server()->Start()); 38 ASSERT_TRUE(test_server()->Start());
25 ASSERT_TRUE(RunExtensionTest("page_action/basics")) << message_; 39 ASSERT_TRUE(RunExtensionTest("page_action/basics")) << message_;
26 const Extension* extension = GetSingleLoadedExtension(); 40 const Extension* extension = GetSingleLoadedExtension();
27 ASSERT_TRUE(extension) << message_; 41 ASSERT_TRUE(extension) << message_;
28 { 42 {
29 // Tell the extension to update the page action state. 43 // Tell the extension to update the page action state.
30 ResultCatcher catcher; 44 ResultCatcher catcher;
31 ui_test_utils::NavigateToURL(browser(), 45 ui_test_utils::NavigateToURL(browser(),
(...skipping 20 matching lines...) Expand all
52 } 66 }
53 67
54 { 68 {
55 // Tell the extension to update the page action state again. 69 // Tell the extension to update the page action state again.
56 ResultCatcher catcher; 70 ResultCatcher catcher;
57 ui_test_utils::NavigateToURL(browser(), 71 ui_test_utils::NavigateToURL(browser(),
58 GURL(extension->GetResourceURL("update2.html"))); 72 GURL(extension->GetResourceURL("update2.html")));
59 ASSERT_TRUE(catcher.GetNextResult()); 73 ASSERT_TRUE(catcher.GetNextResult());
60 } 74 }
61 75
76 MockActionIconFactory mock_icon_factory;
77 EXPECT_CALL(mock_icon_factory, GetIcon(_, _)).Times(0);
78
62 // Test that we received the changes. 79 // Test that we received the changes.
63 tab_id = chrome::GetActiveTabContents(browser())->restore_tab_helper()-> 80 tab_id = chrome::GetActiveTabContents(browser())->restore_tab_helper()->
64 session_id().id(); 81 session_id().id();
65 EXPECT_FALSE(action->GetIcon(tab_id).IsEmpty()); 82 EXPECT_FALSE(action->GetIcon(tab_id, &mock_icon_factory).IsEmpty());
66 } 83 }
67 84
68 // Test that calling chrome.pageAction.setPopup() can enable a popup. 85 // Test that calling chrome.pageAction.setPopup() can enable a popup.
69 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) { 86 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, PageActionAddPopup) {
70 // Load the extension, which has no default popup. 87 // Load the extension, which has no default popup.
71 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_; 88 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_;
72 const Extension* extension = GetSingleLoadedExtension(); 89 const Extension* extension = GetSingleLoadedExtension();
73 ASSERT_TRUE(extension) << message_; 90 ASSERT_TRUE(extension) << message_;
74 91
75 int tab_id = ExtensionTabUtil::GetTabId( 92 int tab_id = ExtensionTabUtil::GetTabId(
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Getters) { 221 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Getters) {
205 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_; 222 ASSERT_TRUE(RunExtensionTest("page_action/getters")) << message_;
206 const Extension* extension = GetSingleLoadedExtension(); 223 const Extension* extension = GetSingleLoadedExtension();
207 ASSERT_TRUE(extension) << message_; 224 ASSERT_TRUE(extension) << message_;
208 225
209 ResultCatcher catcher; 226 ResultCatcher catcher;
210 ui_test_utils::NavigateToURL(browser(), 227 ui_test_utils::NavigateToURL(browser(),
211 GURL(extension->GetResourceURL("update.html"))); 228 GURL(extension->GetResourceURL("update.html")));
212 ASSERT_TRUE(catcher.GetNextResult()); 229 ASSERT_TRUE(catcher.GetNextResult());
213 } 230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698