| OLD | NEW |
| 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 "chrome/browser/themes/theme_service.h" | 5 #include "chrome/browser/themes/theme_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_service_test_base.h" | 16 #include "chrome/browser/extensions/extension_service_test_base.h" |
| 17 #include "chrome/browser/extensions/unpacked_installer.h" | 17 #include "chrome/browser/extensions/unpacked_installer.h" |
| 18 #include "chrome/browser/themes/custom_theme_supplier.h" | 18 #include "chrome/browser/themes/custom_theme_supplier.h" |
| 19 #include "chrome/browser/themes/theme_properties.h" | 19 #include "chrome/browser/themes/theme_properties.h" |
| 20 #include "chrome/browser/themes/theme_service_factory.h" | 20 #include "chrome/browser/themes/theme_service_factory.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/features.h" |
| 22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/test/base/testing_browser_process.h" | 24 #include "chrome/test/base/testing_browser_process.h" |
| 24 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 25 #include "chrome/test/base/testing_profile_manager.h" | 26 #include "chrome/test/base/testing_profile_manager.h" |
| 26 #include "content/public/browser/notification_observer.h" | 27 #include "content/public/browser/notification_observer.h" |
| 27 #include "content/public/browser/notification_registrar.h" | 28 #include "content/public/browser/notification_registrar.h" |
| 28 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
| 29 #include "extensions/browser/extension_registry.h" | 30 #include "extensions/browser/extension_registry.h" |
| 30 #include "extensions/browser/test_extension_registry_observer.h" | 31 #include "extensions/browser/test_extension_registry_observer.h" |
| 31 #include "extensions/browser/uninstall_reason.h" | 32 #include "extensions/browser/uninstall_reason.h" |
| 32 #include "extensions/common/extension.h" | 33 #include "extensions/common/extension.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "ui/base/material_design/material_design_controller.h" | 35 #include "ui/base/material_design/material_design_controller.h" |
| 35 #include "ui/base/test/material_design_controller_test_api.h" | 36 #include "ui/base/test/material_design_controller_test_api.h" |
| 36 #include "ui/base/ui_base_switches.h" | 37 #include "ui/base/ui_base_switches.h" |
| 37 | 38 |
| 38 #if defined(ENABLE_SUPERVISED_USERS) | 39 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 39 #include "chrome/browser/supervised_user/supervised_user_service.h" | 40 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 40 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 41 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 41 #endif | 42 #endif |
| 42 | 43 |
| 43 using extensions::ExtensionRegistry; | 44 using extensions::ExtensionRegistry; |
| 44 | 45 |
| 45 namespace theme_service_internal { | 46 namespace theme_service_internal { |
| 46 | 47 |
| 47 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { | 48 class ThemeServiceTest : public extensions::ExtensionServiceTestBase { |
| 48 public: | 49 public: |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 const std::string& extension2_id = LoadUnpackedThemeAt(temp_dir2.GetPath()); | 352 const std::string& extension2_id = LoadUnpackedThemeAt(temp_dir2.GetPath()); |
| 352 ASSERT_EQ(extension2_id, theme_service->GetThemeID()); | 353 ASSERT_EQ(extension2_id, theme_service->GetThemeID()); |
| 353 ASSERT_FALSE(service_->GetInstalledExtension(extension1_id)); | 354 ASSERT_FALSE(service_->GetInstalledExtension(extension1_id)); |
| 354 } | 355 } |
| 355 | 356 |
| 356 // Check that it is possible to reinstall extension1. | 357 // Check that it is possible to reinstall extension1. |
| 357 ASSERT_EQ(extension1_id, LoadUnpackedThemeAt(temp_dir1.GetPath())); | 358 ASSERT_EQ(extension1_id, LoadUnpackedThemeAt(temp_dir1.GetPath())); |
| 358 EXPECT_EQ(extension1_id, theme_service->GetThemeID()); | 359 EXPECT_EQ(extension1_id, theme_service->GetThemeID()); |
| 359 } | 360 } |
| 360 | 361 |
| 361 #if defined(ENABLE_SUPERVISED_USERS) | 362 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 362 class ThemeServiceSupervisedUserTest : public ThemeServiceTest { | 363 class ThemeServiceSupervisedUserTest : public ThemeServiceTest { |
| 363 public: | 364 public: |
| 364 ThemeServiceSupervisedUserTest() {} | 365 ThemeServiceSupervisedUserTest() {} |
| 365 ~ThemeServiceSupervisedUserTest() override {} | 366 ~ThemeServiceSupervisedUserTest() override {} |
| 366 | 367 |
| 367 void SetUp() override { | 368 void SetUp() override { |
| 368 is_supervised_ = true; | 369 is_supervised_ = true; |
| 369 ThemeServiceTest::SetUp(); | 370 ThemeServiceTest::SetUp(); |
| 370 } | 371 } |
| 371 }; | 372 }; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 389 profile_->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true); | 390 profile_->GetPrefs()->SetBoolean(prefs::kUsesSystemTheme, true); |
| 390 ThemeService* theme_service = | 391 ThemeService* theme_service = |
| 391 ThemeServiceFactory::GetForProfile(profile_.get()); | 392 ThemeServiceFactory::GetForProfile(profile_.get()); |
| 392 theme_service->UseDefaultTheme(); | 393 theme_service->UseDefaultTheme(); |
| 393 EXPECT_TRUE(theme_service->UsingDefaultTheme()); | 394 EXPECT_TRUE(theme_service->UsingDefaultTheme()); |
| 394 EXPECT_TRUE(get_theme_supplier(theme_service)); | 395 EXPECT_TRUE(get_theme_supplier(theme_service)); |
| 395 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), | 396 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), |
| 396 CustomThemeSupplier::SUPERVISED_USER_THEME); | 397 CustomThemeSupplier::SUPERVISED_USER_THEME); |
| 397 } | 398 } |
| 398 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) | 399 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 399 #endif // defined(ENABLE_SUPERVISED_USERS) | 400 #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) |
| 400 | 401 |
| 401 #if !defined(OS_MACOSX) // Mac uses different colors than other platforms. | 402 #if !defined(OS_MACOSX) // Mac uses different colors than other platforms. |
| 402 // Simple class to run tests in material design mode. | 403 // Simple class to run tests in material design mode. |
| 403 class ThemeServiceMaterialDesignTest : public ThemeServiceTest { | 404 class ThemeServiceMaterialDesignTest : public ThemeServiceTest { |
| 404 public: | 405 public: |
| 405 void SetUp() override { | 406 void SetUp() override { |
| 406 ThemeServiceTest::SetUp(); | 407 ThemeServiceTest::SetUp(); |
| 407 material_design_state_.reset( | 408 material_design_state_.reset( |
| 408 new ui::test::MaterialDesignControllerTestAPI( | 409 new ui::test::MaterialDesignControllerTestAPI( |
| 409 ui::MaterialDesignController::MATERIAL_NORMAL)); | 410 ui::MaterialDesignController::MATERIAL_NORMAL)); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // it should still be lighter than the tab color. | 523 // it should still be lighter than the tab color. |
| 523 separator_color = GetSeparatorColor(tab_color, SK_ColorWHITE); | 524 separator_color = GetSeparatorColor(tab_color, SK_ColorWHITE); |
| 524 separator_luminance = color_utils::GetRelativeLuminance(separator_color); | 525 separator_luminance = color_utils::GetRelativeLuminance(separator_color); |
| 525 EXPECT_LT(separator_luminance, 1); | 526 EXPECT_LT(separator_luminance, 1); |
| 526 EXPECT_GT(separator_luminance, tab_luminance); | 527 EXPECT_GT(separator_luminance, tab_luminance); |
| 527 } | 528 } |
| 528 } | 529 } |
| 529 #endif // !defined(OS_MACOSX) | 530 #endif // !defined(OS_MACOSX) |
| 530 | 531 |
| 531 }; // namespace theme_service_internal | 532 }; // namespace theme_service_internal |
| OLD | NEW |