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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/user_script_master.h" 13 #include "chrome/browser/extensions/user_script_master.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
21 #include "content/browser/tab_contents/tab_contents.h"
22 #include "content/public/browser/notification_details.h" 21 #include "content/public/browser/notification_details.h"
23 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/web_contents.h"
24 #include "net/base/net_util.h" 24 #include "net/base/net_util.h"
25 25
26 // This file contains high-level startup tests for the extensions system. We've 26 // This file contains high-level startup tests for the extensions system. We've
27 // had many silly bugs where command line flags did not get propagated correctly 27 // had many silly bugs where command line flags did not get propagated correctly
28 // into the services, so we didn't start correctly. 28 // into the services, so we didn't start correctly.
29 29
30 class ExtensionStartupTestBase : public InProcessBrowserTest { 30 class ExtensionStartupTestBase : public InProcessBrowserTest {
31 public: 31 public:
32 ExtensionStartupTestBase() : enable_extensions_(false) { 32 ExtensionStartupTestBase() : enable_extensions_(false) {
33 num_expected_extensions_ = 3; 33 num_expected_extensions_ = 3;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Load a page affected by the content script and test to see the effect. 108 // Load a page affected by the content script and test to see the effect.
109 FilePath test_file; 109 FilePath test_file;
110 PathService::Get(chrome::DIR_TEST_DATA, &test_file); 110 PathService::Get(chrome::DIR_TEST_DATA, &test_file);
111 test_file = test_file.AppendASCII("extensions") 111 test_file = test_file.AppendASCII("extensions")
112 .AppendASCII("test_file.html"); 112 .AppendASCII("test_file.html");
113 113
114 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file)); 114 ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(test_file));
115 115
116 bool result = false; 116 bool result = false;
117 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 117 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
118 browser()->GetSelectedTabContents()->GetRenderViewHost(), L"", 118 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
119 L"window.domAutomationController.send(" 119 L"window.domAutomationController.send("
120 L"document.defaultView.getComputedStyle(document.body, null)." 120 L"document.defaultView.getComputedStyle(document.body, null)."
121 L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')", 121 L"getPropertyValue('background-color') == 'rgb(245, 245, 220)')",
122 &result)); 122 &result));
123 EXPECT_EQ(expect_css, result); 123 EXPECT_EQ(expect_css, result);
124 124
125 result = false; 125 result = false;
126 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 126 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
127 browser()->GetSelectedTabContents()->GetRenderViewHost(), L"", 127 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
128 L"window.domAutomationController.send(document.title == 'Modified')", 128 L"window.domAutomationController.send(document.title == 'Modified')",
129 &result)); 129 &result));
130 EXPECT_EQ(expect_script, result); 130 EXPECT_EQ(expect_script, result);
131 } 131 }
132 132
133 FilePath preferences_file_; 133 FilePath preferences_file_;
134 FilePath extensions_dir_; 134 FilePath extensions_dir_;
135 FilePath user_scripts_dir_; 135 FilePath user_scripts_dir_;
136 bool enable_extensions_; 136 bool enable_extensions_;
137 // Extensions to load from the command line. 137 // Extensions to load from the command line.
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 .AppendASCII("extensions") 261 .AppendASCII("extensions")
262 .AppendASCII("app2"); 262 .AppendASCII("app2");
263 load_extensions_.push_back(fourth_extension_path.value()); 263 load_extensions_.push_back(fourth_extension_path.value());
264 } 264 }
265 }; 265 };
266 266
267 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { 267 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) {
268 WaitForServicesToStart(4, true); 268 WaitForServicesToStart(4, true);
269 TestInjection(true, true); 269 TestInjection(true, true);
270 } 270 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698