OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 } | 284 } |
285 | 285 |
286 void InstallThemeSource() { | 286 void InstallThemeSource() { |
287 ThemeSource* theme = new ThemeSource(profile()); | 287 ThemeSource* theme = new ThemeSource(profile()); |
288 content::URLDataSource::Add(profile(), theme); | 288 content::URLDataSource::Add(profile(), theme); |
289 } | 289 } |
290 | 290 |
291 void InstallThemeAndVerify(const std::string& theme_dir, | 291 void InstallThemeAndVerify(const std::string& theme_dir, |
292 const std::string& theme_name) { | 292 const std::string& theme_name) { |
293 const extensions::Extension* theme = | 293 const extensions::Extension* theme = |
294 ThemeServiceFactory::GetThemeForProfile( | 294 ThemeServiceFactory::GetThemeForProfile(profile()); |
295 ExtensionBrowserTest::browser()->profile()); | |
296 // If there is already a theme installed, the current theme should be | 295 // If there is already a theme installed, the current theme should be |
297 // disabled and the new one installed + enabled. | 296 // disabled and the new one installed + enabled. |
298 int expected_change = theme ? 0 : 1; | 297 int expected_change = theme ? 0 : 1; |
299 | 298 |
300 const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_dir); | 299 const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_dir); |
301 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( | 300 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
302 theme_path, expected_change, ExtensionBrowserTest::browser())); | 301 theme_path, expected_change, ExtensionBrowserTest::browser())); |
| 302 content::WindowedNotificationObserver theme_change_observer( |
| 303 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 304 content::Source<ThemeService>( |
| 305 ThemeServiceFactory::GetForProfile(profile()))); |
| 306 theme_change_observer.Wait(); |
303 const extensions::Extension* new_theme = | 307 const extensions::Extension* new_theme = |
304 ThemeServiceFactory::GetThemeForProfile( | 308 ThemeServiceFactory::GetThemeForProfile(profile()); |
305 ExtensionBrowserTest::browser()->profile()); | |
306 ASSERT_NE(static_cast<extensions::Extension*>(NULL), new_theme); | 309 ASSERT_NE(static_cast<extensions::Extension*>(NULL), new_theme); |
307 ASSERT_EQ(new_theme->name(), theme_name); | 310 ASSERT_EQ(new_theme->name(), theme_name); |
308 } | 311 } |
309 | 312 |
310 private: | 313 private: |
311 DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest); | 314 DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest); |
312 }; | 315 }; |
313 | 316 |
314 // TODO(https://crbug.com/678975): Flaky on memory bot (all platforms). | 317 // TODO(https://crbug.com/678975): Flaky on memory bot (all platforms). |
315 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 318 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 stream << "link.href = \"" << result_url.spec() << "\";"; | 736 stream << "link.href = \"" << result_url.spec() << "\";"; |
734 stream << "document.body.appendChild(link);"; | 737 stream << "document.body.appendChild(link);"; |
735 stream << "link.click();"; | 738 stream << "link.click();"; |
736 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); | 739 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); |
737 | 740 |
738 content::WaitForLoadStop(contents); | 741 content::WaitForLoadStop(contents); |
739 std::string expected_title = | 742 std::string expected_title = |
740 "Referrer is " + instant_url().GetWithEmptyPath().spec(); | 743 "Referrer is " + instant_url().GetWithEmptyPath().spec(); |
741 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); | 744 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); |
742 } | 745 } |
OLD | NEW |