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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_background_view_unittest.mm

Issue 2430493002: [Mac] Fix rough-looking profile picker text, especially with a dark theme. (Closed)
Patch Set: Scopify! Created 3 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h"
6
7 #import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
8 #include "ui/base/default_theme_provider.h"
9
10 @class NSVisualEffectView;
11
12 namespace {
13
14 bool ContainsViewOfClass(NSView* view, Class cls) {
15 if ([view isKindOfClass:cls])
16 return true;
17 for (NSView* subview in view.subviews) {
18 if (ContainsViewOfClass(subview, cls))
19 return true;
20 }
21 return false;
22 }
23
24 class TabStripBackgroundViewTest : public CocoaTest {
25 protected:
26 const base::scoped_nsobject<TabStripBackgroundView>
27 tab_strip_background_view_{
28 [[TabStripBackgroundView alloc] initWithFrame:NSZeroRect]};
29 };
30
31 class MockThemeProvider : public ui::DefaultThemeProvider {
32 public:
33 bool UsingSystemTheme() const override { return using_system_theme_; }
34
35 void SetUsingSystemTheme(bool using_system_theme) {
36 using_system_theme_ = using_system_theme;
37 }
38
39 private:
40 bool using_system_theme_ = true;
41 };
42
43 } // namespace
44
45 @interface TabStripBackgroundViewTestWindow : NSWindow
46 @property(nonatomic) const ui::ThemeProvider* themeProvider;
47 @end
48
49 @implementation TabStripBackgroundViewTestWindow
50 @synthesize themeProvider = themeProvider_;
51 @end
52
53 TEST_F(TabStripBackgroundViewTest, TestVisualEffectView) {
54 // TODO(sdy): Remove once we no longer support 10.9.
55 // Skip this test when running on an OS without NSVisualEffectView.
56 if (![NSVisualEffectView class])
57 return;
58
59 auto has_visual_effect_view = [&]() {
60 return ContainsViewOfClass(tab_strip_background_view_,
61 [NSVisualEffectView class]);
62 };
63
64 EXPECT_FALSE(has_visual_effect_view());
65
66 base::scoped_nsobject<TabStripBackgroundViewTestWindow>
67 scoped_window([[TabStripBackgroundViewTestWindow alloc] init]);
68 TabStripBackgroundViewTestWindow* window = scoped_window.get();
69
70 MockThemeProvider theme_provider;
71 window.themeProvider = &theme_provider;
72
73 [window.contentView addSubview:tab_strip_background_view_];
74
75 [window makeKeyAndOrderFront:nil];
76 [tab_strip_background_view_ windowDidChangeActive];
77 EXPECT_TRUE(has_visual_effect_view());
78
79 window.styleMask |= NSFullScreenWindowMask;
80 EXPECT_FALSE(has_visual_effect_view());
81
82 window.styleMask &= ~NSFullScreenWindowMask;
83 EXPECT_TRUE(has_visual_effect_view());
84
85 theme_provider.SetUsingSystemTheme(false);
86 [tab_strip_background_view_ windowDidChangeTheme];
87 EXPECT_FALSE(has_visual_effect_view());
88
89 theme_provider.SetUsingSystemTheme(true);
90 [tab_strip_background_view_ windowDidChangeTheme];
91 EXPECT_TRUE(has_visual_effect_view());
92 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_strip_background_view.mm ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698