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/themes/theme_service_unittest.cc

Issue 2473863004: Remove MaterialDesignController::IsModeMaterial (Closed)
Patch Set: pkasting review and rebase Created 4 years, 1 month 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 "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"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/test/base/testing_profile.h" 25 #include "chrome/test/base/testing_profile.h"
26 #include "chrome/test/base/testing_profile_manager.h" 26 #include "chrome/test/base/testing_profile_manager.h"
27 #include "content/public/browser/notification_observer.h" 27 #include "content/public/browser/notification_observer.h"
28 #include "content/public/browser/notification_registrar.h" 28 #include "content/public/browser/notification_registrar.h"
29 #include "content/public/test/test_utils.h" 29 #include "content/public/test/test_utils.h"
30 #include "extensions/browser/extension_registry.h" 30 #include "extensions/browser/extension_registry.h"
31 #include "extensions/browser/test_extension_registry_observer.h" 31 #include "extensions/browser/test_extension_registry_observer.h"
32 #include "extensions/browser/uninstall_reason.h" 32 #include "extensions/browser/uninstall_reason.h"
33 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
35 #include "ui/base/material_design/material_design_controller.h"
36 #include "ui/base/test/material_design_controller_test_api.h"
37 #include "ui/base/ui_base_switches.h" 35 #include "ui/base/ui_base_switches.h"
38 36
39 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) 37 #if BUILDFLAG(ENABLE_SUPERVISED_USERS)
40 #include "chrome/browser/supervised_user/supervised_user_service.h" 38 #include "chrome/browser/supervised_user/supervised_user_service.h"
41 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 39 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
42 #endif 40 #endif
43 41
44 using extensions::ExtensionRegistry; 42 using extensions::ExtensionRegistry;
45 43
46 namespace theme_service_internal { 44 namespace theme_service_internal {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 EXPECT_EQ(theme_service, otr_theme_service); 276 EXPECT_EQ(theme_service, otr_theme_service);
279 277
280 #if !defined(OS_MACOSX) 278 #if !defined(OS_MACOSX)
281 // Should get a different ThemeProvider for incognito and original profiles. 279 // Should get a different ThemeProvider for incognito and original profiles.
282 const ui::ThemeProvider& provider = 280 const ui::ThemeProvider& provider =
283 ThemeService::GetThemeProviderForProfile(profile_.get()); 281 ThemeService::GetThemeProviderForProfile(profile_.get());
284 const ui::ThemeProvider& otr_provider = 282 const ui::ThemeProvider& otr_provider =
285 ThemeService::GetThemeProviderForProfile( 283 ThemeService::GetThemeProviderForProfile(
286 profile_->GetOffTheRecordProfile()); 284 profile_->GetOffTheRecordProfile());
287 EXPECT_NE(&provider, &otr_provider); 285 EXPECT_NE(&provider, &otr_provider);
288 // And (some) colors should be different in MD mode. 286 // And (some) colors should be different.
289 if (ui::MaterialDesignController::IsModeMaterial()) { 287 EXPECT_NE(provider.GetColor(ThemeProperties::COLOR_TOOLBAR),
290 EXPECT_NE(provider.GetColor(ThemeProperties::COLOR_TOOLBAR), 288 otr_provider.GetColor(ThemeProperties::COLOR_TOOLBAR));
291 otr_provider.GetColor(ThemeProperties::COLOR_TOOLBAR));
292 }
293 #endif 289 #endif
294 } 290 }
295 291
296 namespace { 292 namespace {
297 293
298 // NotificationObserver which emulates an infobar getting destroyed when the 294 // NotificationObserver which emulates an infobar getting destroyed when the
299 // theme changes. 295 // theme changes.
300 class InfobarDestroyerOnThemeChange : public content::NotificationObserver { 296 class InfobarDestroyerOnThemeChange : public content::NotificationObserver {
301 public: 297 public:
302 explicit InfobarDestroyerOnThemeChange(Profile* profile) 298 explicit InfobarDestroyerOnThemeChange(Profile* profile)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 theme_service->UseDefaultTheme(); 389 theme_service->UseDefaultTheme();
394 EXPECT_TRUE(theme_service->UsingDefaultTheme()); 390 EXPECT_TRUE(theme_service->UsingDefaultTheme());
395 EXPECT_TRUE(get_theme_supplier(theme_service)); 391 EXPECT_TRUE(get_theme_supplier(theme_service));
396 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(), 392 EXPECT_EQ(get_theme_supplier(theme_service)->get_theme_type(),
397 CustomThemeSupplier::SUPERVISED_USER_THEME); 393 CustomThemeSupplier::SUPERVISED_USER_THEME);
398 } 394 }
399 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS) 395 #endif // defined(OS_LINUX) && !defined(OS_CHROMEOS)
400 #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS) 396 #endif // BUILDFLAG(ENABLE_SUPERVISED_USERS)
401 397
402 #if !defined(OS_MACOSX) // Mac uses different colors than other platforms. 398 #if !defined(OS_MACOSX) // Mac uses different colors than other platforms.
403 // Simple class to run tests in material design mode.
404 class ThemeServiceMaterialDesignTest : public ThemeServiceTest {
405 public:
406 void SetUp() override {
407 ThemeServiceTest::SetUp();
408 material_design_state_.reset(
409 new ui::test::MaterialDesignControllerTestAPI(
410 ui::MaterialDesignController::MATERIAL_NORMAL));
411 }
412
413 void TearDown() override {
414 material_design_state_.reset();
415 ThemeServiceTest::TearDown();
416 }
417
418 private:
419 std::unique_ptr<ui::test::MaterialDesignControllerTestAPI>
420 material_design_state_;
421 };
422
423 // Check that the function which computes the separator color behaves as 399 // Check that the function which computes the separator color behaves as
424 // expected for a variety of inputs. We run in material design mode so we can 400 // expected for a variety of inputs.
425 // use the material normal and incognito color combinations, which differ from 401 TEST_F(ThemeServiceTest, SeparatorColor) {
426 // each other in ways that are interesting to test.
427 TEST_F(ThemeServiceMaterialDesignTest, SeparatorColor) {
428 // Ensure Windows 10 machines use the built-in default colors rather than the 402 // Ensure Windows 10 machines use the built-in default colors rather than the
429 // current system native colors. 403 // current system native colors.
430 base::CommandLine::ForCurrentProcess()->AppendSwitch( 404 base::CommandLine::ForCurrentProcess()->AppendSwitch(
431 switches::kDisableDwmComposition); 405 switches::kDisableDwmComposition);
432 406
433 { 407 {
434 const ui::ThemeProvider& theme_provider = 408 const ui::ThemeProvider& theme_provider =
435 ThemeService::GetThemeProviderForProfile(profile_.get()); 409 ThemeService::GetThemeProviderForProfile(profile_.get());
436 const SkColor frame_color = 410 const SkColor frame_color =
437 theme_provider.GetColor(ThemeProperties::COLOR_FRAME); 411 theme_provider.GetColor(ThemeProperties::COLOR_FRAME);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 // it should still be lighter than the tab color. 497 // it should still be lighter than the tab color.
524 separator_color = GetSeparatorColor(tab_color, SK_ColorWHITE); 498 separator_color = GetSeparatorColor(tab_color, SK_ColorWHITE);
525 separator_luminance = color_utils::GetRelativeLuminance(separator_color); 499 separator_luminance = color_utils::GetRelativeLuminance(separator_color);
526 EXPECT_LT(separator_luminance, 1); 500 EXPECT_LT(separator_luminance, 1);
527 EXPECT_GT(separator_luminance, tab_luminance); 501 EXPECT_GT(separator_luminance, tab_luminance);
528 } 502 }
529 } 503 }
530 #endif // !defined(OS_MACOSX) 504 #endif // !defined(OS_MACOSX)
531 505
532 }; // namespace theme_service_internal 506 }; // namespace theme_service_internal
OLDNEW
« no previous file with comments | « chrome/browser/themes/theme_service_mac.mm ('k') | chrome/browser/ui/cocoa/infobars/infobar_gradient_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698