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

Side by Side Diff: chrome/browser/extensions/extension_keybinding_apitest.cc

Issue 1104813005: [Extensions Toolbar] Refactor a few test classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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/app/chrome_command_ids.h" 6 #include "chrome/app/chrome_command_ids.h"
7 #include "chrome/browser/extensions/active_tab_permission_granter.h" 7 #include "chrome/browser/extensions/active_tab_permission_granter.h"
8 #include "chrome/browser/extensions/api/commands/command_service.h" 8 #include "chrome/browser/extensions/api/commands/command_service.h"
9 #include "chrome/browser/extensions/browser_action_test_util.h" 9 #include "chrome/browser/extensions/browser_action_test_util.h"
10 #include "chrome/browser/extensions/component_loader.h" 10 #include "chrome/browser/extensions/component_loader.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 } // namespace 128 } // namespace
129 129
130 class CommandsApiTest : public ExtensionApiTest { 130 class CommandsApiTest : public ExtensionApiTest {
131 public: 131 public:
132 CommandsApiTest() {} 132 CommandsApiTest() {}
133 ~CommandsApiTest() override {} 133 ~CommandsApiTest() override {}
134 134
135 protected: 135 protected:
136 BrowserActionTestUtil GetBrowserActionsBar() {
137 return BrowserActionTestUtil(browser());
138 }
139
140 bool IsGrantedForTab(const Extension* extension, 136 bool IsGrantedForTab(const Extension* extension,
141 const content::WebContents* web_contents) { 137 const content::WebContents* web_contents) {
142 return extension->permissions_data()->HasAPIPermissionForTab( 138 return extension->permissions_data()->HasAPIPermissionForTab(
143 SessionTabHelper::IdForTab(web_contents), APIPermission::kTab); 139 SessionTabHelper::IdForTab(web_contents), APIPermission::kTab);
144 } 140 }
145 141
146 #if defined(OS_CHROMEOS) 142 #if defined(OS_CHROMEOS)
147 void RunChromeOSConversionTest(const std::string& extension_path) { 143 void RunChromeOSConversionTest(const std::string& extension_path) {
148 // Setup the environment. 144 // Setup the environment.
149 ASSERT_TRUE(test_server()->Start()); 145 ASSERT_TRUE(test_server()->Start());
(...skipping 30 matching lines...) Expand all
180 ASSERT_TRUE(RunExtensionTest("keybinding/basics")) << message_; 176 ASSERT_TRUE(RunExtensionTest("keybinding/basics")) << message_;
181 const Extension* extension = GetSingleLoadedExtension(); 177 const Extension* extension = GetSingleLoadedExtension();
182 ASSERT_TRUE(extension) << message_; 178 ASSERT_TRUE(extension) << message_;
183 179
184 // Load this extension, which uses the same keybindings but sets the page 180 // Load this extension, which uses the same keybindings but sets the page
185 // to different colors. This is so we can see that it doesn't interfere. We 181 // to different colors. This is so we can see that it doesn't interfere. We
186 // don't test this extension in any other way (it should otherwise be 182 // don't test this extension in any other way (it should otherwise be
187 // immaterial to this test). 183 // immaterial to this test).
188 ASSERT_TRUE(RunExtensionTest("keybinding/conflicting")) << message_; 184 ASSERT_TRUE(RunExtensionTest("keybinding/conflicting")) << message_;
189 185
186 BrowserActionTestUtil browser_actions_bar(browser());
190 // Test that there are two browser actions in the toolbar. 187 // Test that there are two browser actions in the toolbar.
191 ASSERT_EQ(2, GetBrowserActionsBar().NumberOfBrowserActions()); 188 ASSERT_EQ(2, browser_actions_bar.NumberOfBrowserActions());
192 189
193 ui_test_utils::NavigateToURL( 190 ui_test_utils::NavigateToURL(
194 browser(), test_server()->GetURL("files/extensions/test_file.txt")); 191 browser(), test_server()->GetURL("files/extensions/test_file.txt"));
195 192
196 // activeTab shouldn't have been granted yet. 193 // activeTab shouldn't have been granted yet.
197 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); 194 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
198 ASSERT_TRUE(tab); 195 ASSERT_TRUE(tab);
199 196
200 EXPECT_FALSE(IsGrantedForTab(extension, tab)); 197 EXPECT_FALSE(IsGrantedForTab(extension, tab));
201 198
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 963
967 extensions::ExtensionSystem::Get(browser()->profile()) 964 extensions::ExtensionSystem::Get(browser()->profile())
968 ->extension_service() 965 ->extension_service()
969 ->component_loader() 966 ->component_loader()
970 ->Remove("pkplfbidichfdicaijlchgnapepdginl"); 967 ->Remove("pkplfbidichfdicaijlchgnapepdginl");
971 968
972 ASSERT_TRUE(RunComponentExtensionTest("keybinding/component")) << message_; 969 ASSERT_TRUE(RunComponentExtensionTest("keybinding/component")) << message_;
973 } 970 }
974 971
975 } // namespace extensions 972 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698