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

Side by Side Diff: chrome/browser/extensions/api/extension_action/page_as_browser_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 "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_prefs.h" 8 #include "chrome/browser/extensions/extension_prefs.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_tab_util.h" 10 #include "chrome/browser/extensions/extension_tab_util.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/sessions/restore_tab_helper.h" 12 #include "chrome/browser/sessions/restore_tab_helper.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_tabstrip.h" 14 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/omnibox/location_bar.h" 16 #include "chrome/browser/ui/omnibox/location_bar.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_action.h" 20 #include "chrome/common/extensions/extension_action.h"
21 #include "chrome/test/base/ui_test_utils.h" 21 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "testing/gmock/include/gmock/gmock.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
25 // browser_actions_apitest.cc. 26 // browser_actions_apitest.cc.
26 27
27 using extensions::Extension; 28 using extensions::Extension;
29 using ::testing::_;
28 30
29 namespace { 31 namespace {
30 32
33 class MockActionIconFactory : public ExtensionAction::IconFactory {
34 public:
35 virtual ~MockActionIconFactory() {}
36
37 MOCK_METHOD2(GetIcon, gfx::ImageSkia(const ExtensionIconSet* icon_set,
38 ExtensionAction::Type type));
39 };
40
31 class PageAsBrowserActionApiTest : public ExtensionApiTest { 41 class PageAsBrowserActionApiTest : public ExtensionApiTest {
32 public: 42 public:
33 PageAsBrowserActionApiTest() {} 43 PageAsBrowserActionApiTest() {}
34 virtual ~PageAsBrowserActionApiTest() {} 44 virtual ~PageAsBrowserActionApiTest() {}
35 45
36 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 46 void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
37 ExtensionApiTest::SetUpCommandLine(command_line); 47 ExtensionApiTest::SetUpCommandLine(command_line);
38 command_line->AppendSwitch(switches::kEnableScriptBadges); 48 command_line->AppendSwitch(switches::kEnableScriptBadges);
39 } 49 }
40 50
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 97 }
88 98
89 { 99 {
90 // Tell the extension to update the page action state again. 100 // Tell the extension to update the page action state again.
91 ResultCatcher catcher; 101 ResultCatcher catcher;
92 ui_test_utils::NavigateToURL(browser(), 102 ui_test_utils::NavigateToURL(browser(),
93 GURL(extension->GetResourceURL("update2.html"))); 103 GURL(extension->GetResourceURL("update2.html")));
94 ASSERT_TRUE(catcher.GetNextResult()); 104 ASSERT_TRUE(catcher.GetNextResult());
95 } 105 }
96 106
107 MockActionIconFactory mock_icon_factory;
108 EXPECT_CALL(mock_icon_factory, GetIcon(_, _)).Times(0);
109
97 // Test that we received the changes. 110 // Test that we received the changes.
98 EXPECT_FALSE(action->GetIcon(tab_id).IsEmpty()); 111 EXPECT_FALSE(action->GetIcon(tab_id, &mock_icon_factory).IsEmpty());
99 } 112 }
100 113
101 // Test that calling chrome.pageAction.setPopup() can enable a popup. 114 // Test that calling chrome.pageAction.setPopup() can enable a popup.
102 IN_PROC_BROWSER_TEST_F(PageAsBrowserActionApiTest, AddPopup) { 115 IN_PROC_BROWSER_TEST_F(PageAsBrowserActionApiTest, AddPopup) {
103 // Load the extension, which has no default popup. 116 // Load the extension, which has no default popup.
104 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_; 117 ASSERT_TRUE(RunExtensionTest("page_action/add_popup")) << message_;
105 const Extension* extension = GetSingleLoadedExtension(); 118 const Extension* extension = GetSingleLoadedExtension();
106 ASSERT_TRUE(extension) << message_; 119 ASSERT_TRUE(extension) << message_;
107 120
108 int tab_id = ExtensionTabUtil::GetTabId( 121 int tab_id = ExtensionTabUtil::GetTabId(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 const Extension* extension = GetSingleLoadedExtension(); 192 const Extension* extension = GetSingleLoadedExtension();
180 ASSERT_TRUE(extension) << message_; 193 ASSERT_TRUE(extension) << message_;
181 194
182 ResultCatcher catcher; 195 ResultCatcher catcher;
183 ui_test_utils::NavigateToURL(browser(), 196 ui_test_utils::NavigateToURL(browser(),
184 GURL(extension->GetResourceURL("update.html"))); 197 GURL(extension->GetResourceURL("update.html")));
185 ASSERT_TRUE(catcher.GetNextResult()); 198 ASSERT_TRUE(catcher.GetNextResult());
186 } 199 }
187 200
188 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698