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

Unified 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: Add theme tests 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/tabs/tab_strip_background_view_unittest.mm
diff --git a/chrome/browser/ui/cocoa/tabs/tab_strip_background_view_unittest.mm b/chrome/browser/ui/cocoa/tabs/tab_strip_background_view_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7c45b52181487733cd98cad6f739f300fc10738b
--- /dev/null
+++ b/chrome/browser/ui/cocoa/tabs/tab_strip_background_view_unittest.mm
@@ -0,0 +1,87 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/ui/cocoa/tabs/tab_strip_background_view_private.h"
+
+#import "chrome/browser/ui/cocoa/test/cocoa_test_helper.h"
+#include "ui/base/default_theme_provider.h"
+
+@class NSVisualEffectView;
+
+namespace {
+
+bool ContainsViewOfClass(NSView* view, Class cls) {
+ if ([view isKindOfClass:cls])
+ return true;
+ for (NSView* subview in view.subviews)
spqchan 2017/01/11 19:33:56 nit: multiple statement for loops need curly brace
Sidney San Martín 2017/01/13 00:10:07 Done.
+ if (ContainsViewOfClass(subview, cls))
+ return true;
+ return false;
+}
+
+class TabStripBackgroundViewTest : public CocoaTest {
+ protected:
+ const base::scoped_nsobject<TabStripBackgroundView> tabStripBackgroundView_{
Robert Sesek 2017/01/11 19:23:40 naming: use under_scores_ in C++ members
Sidney San Martín 2017/01/13 00:10:07 Done.
+ [[TabStripBackgroundView alloc] initWithFrame:NSZeroRect]};
+};
+
+class MockThemeProvider : public ui::DefaultThemeProvider {
+ public:
+ bool UsingSystemTheme() const override { return _usingSystemTheme; }
+
+ void SetUsingSystemTheme(bool usingSystemTheme) {
+ _usingSystemTheme = usingSystemTheme;
+ }
+
+ private:
+ bool _usingSystemTheme = true;
Robert Sesek 2017/01/11 19:23:40 naming: under_scores_
Sidney San Martín 2017/01/13 00:10:07 Done.
+};
+
+} // namespace
+
+@interface TabStripBackgroundViewTestWindow : NSWindow
+@property(nonatomic) const ui::ThemeProvider* themeProvider;
+@end
+
+@implementation TabStripBackgroundViewTestWindow
+@synthesize themeProvider = _themeProvider;
Robert Sesek 2017/01/11 19:23:40 nit: Use trailing underscore.
Sidney San Martín 2017/01/13 00:10:07 Done.
+@end
+
+TEST_F(TabStripBackgroundViewTest, TestVisualEffectView) {
+ Class NSVisualEffectView_class = [NSVisualEffectView class];
Robert Sesek 2017/01/11 19:23:40 Leave a comment explaining what this is doing.
Sidney San Martín 2017/01/13 00:10:07 Done.
+ if (!NSVisualEffectView_class)
+ return;
+
+ auto hasVisualEffectView = [&]() {
Robert Sesek 2017/01/11 19:23:40 naming: under_scores
Sidney San Martín 2017/01/13 00:10:07 Done.
+ return ContainsViewOfClass(tabStripBackgroundView_,
+ NSVisualEffectView_class);
+ };
+
+ EXPECT_FALSE(hasVisualEffectView());
+
+ TabStripBackgroundViewTestWindow* window =
+ [[[TabStripBackgroundViewTestWindow alloc] init] autorelease];
+ MockThemeProvider themeProvider;
Robert Sesek 2017/01/11 19:23:40 naming: under_scores
Sidney San Martín 2017/01/13 00:10:07 Done.
+ window.themeProvider = &themeProvider;
+
+ [window.contentView addSubview:tabStripBackgroundView_];
+
+ [window makeKeyAndOrderFront:nil];
+ [tabStripBackgroundView_ windowDidChangeActive];
+ EXPECT_TRUE(hasVisualEffectView());
+
+ window.styleMask |= NSFullScreenWindowMask;
+ EXPECT_FALSE(hasVisualEffectView());
+
+ window.styleMask &= ~NSFullScreenWindowMask;
+ EXPECT_TRUE(hasVisualEffectView());
+
+ themeProvider.SetUsingSystemTheme(false);
+ [tabStripBackgroundView_ windowDidChangeTheme];
+ EXPECT_FALSE(hasVisualEffectView());
+
+ themeProvider.SetUsingSystemTheme(true);
+ [tabStripBackgroundView_ windowDidChangeTheme];
+ EXPECT_TRUE(hasVisualEffectView());
+}

Powered by Google App Engine
This is Rietveld 408576698