| 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(profile()); | 294 ThemeServiceFactory::GetThemeForProfile( |
| 295 ExtensionBrowserTest::browser()->profile()); |
| 295 // If there is already a theme installed, the current theme should be | 296 // If there is already a theme installed, the current theme should be |
| 296 // disabled and the new one installed + enabled. | 297 // disabled and the new one installed + enabled. |
| 297 int expected_change = theme ? 0 : 1; | 298 int expected_change = theme ? 0 : 1; |
| 298 | 299 |
| 299 const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_dir); | 300 const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_dir); |
| 300 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( | 301 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( |
| 301 theme_path, expected_change, ExtensionBrowserTest::browser())); | 302 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(); | |
| 307 const extensions::Extension* new_theme = | 303 const extensions::Extension* new_theme = |
| 308 ThemeServiceFactory::GetThemeForProfile(profile()); | 304 ThemeServiceFactory::GetThemeForProfile( |
| 305 ExtensionBrowserTest::browser()->profile()); |
| 309 ASSERT_NE(static_cast<extensions::Extension*>(NULL), new_theme); | 306 ASSERT_NE(static_cast<extensions::Extension*>(NULL), new_theme); |
| 310 ASSERT_EQ(new_theme->name(), theme_name); | 307 ASSERT_EQ(new_theme->name(), theme_name); |
| 311 } | 308 } |
| 312 | 309 |
| 313 private: | 310 private: |
| 314 DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest); | 311 DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest); |
| 315 }; | 312 }; |
| 316 | 313 |
| 317 // TODO(https://crbug.com/678975): Flaky on memory bot (all platforms). | 314 // TODO(https://crbug.com/678975): Flaky on memory bot (all platforms). |
| 318 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | 315 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 stream << "link.href = \"" << result_url.spec() << "\";"; | 733 stream << "link.href = \"" << result_url.spec() << "\";"; |
| 737 stream << "document.body.appendChild(link);"; | 734 stream << "document.body.appendChild(link);"; |
| 738 stream << "link.click();"; | 735 stream << "link.click();"; |
| 739 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); | 736 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); |
| 740 | 737 |
| 741 content::WaitForLoadStop(contents); | 738 content::WaitForLoadStop(contents); |
| 742 std::string expected_title = | 739 std::string expected_title = |
| 743 "Referrer is " + instant_url().GetWithEmptyPath().spec(); | 740 "Referrer is " + instant_url().GetWithEmptyPath().spec(); |
| 744 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); | 741 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); |
| 745 } | 742 } |
| OLD | NEW |