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

Unified Diff: chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm

Issue 2636473003: [Mac] Update the Text Color for the Avatar Button (Closed)
Patch Set: Added comment 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
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm b/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm
index 8e7d6d3abc3e4d060edd9372135010e0fd2a131f..08baac5baa173087ad61d6edf5c044f2eec8a87e 100644
--- a/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/profiles/avatar_button_controller_unittest.mm
@@ -27,6 +27,30 @@
// Defined in the AvatarButtonController implementation.
@interface AvatarButtonController (ExposedForTesting)
- (void)setErrorStatus:(BOOL)hasError;
+- (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent;
+@end
+
+// Mocks the AvatarButtonController class so that we can mock its browser
+// window's frame color.
+@interface MockAvatarButtonController : AvatarButtonController {
+ // True if the frame color is dark.
+ BOOL isFrameDark_;
+}
+
+- (void)setIsFrameDark:(BOOL)isDark;
+
+@end
+
+@implementation MockAvatarButtonController
+
+- (void)setIsFrameDark:(BOOL)isDark {
+ isFrameDark_ = isDark;
+}
+
+- (BOOL)isFrameColorDark {
+ return isFrameDark_;
+}
+
@end
class AvatarButtonControllerTest : public CocoaProfileTest {
@@ -37,8 +61,9 @@ class AvatarButtonControllerTest : public CocoaProfileTest {
CocoaProfileTest::SetUp();
ASSERT_TRUE(browser());
- controller_.reset(
- [[AvatarButtonController alloc] initWithBrowser:browser()]);
+ controller_.reset([[MockAvatarButtonController alloc]
+ initWithBrowser:browser()
+ window:nil]);
}
void TearDown() override {
@@ -50,10 +75,10 @@ class AvatarButtonControllerTest : public CocoaProfileTest {
NSView* view() { return [controller_ view]; }
- AvatarButtonController* controller() { return controller_.get(); }
+ MockAvatarButtonController* controller() { return controller_.get(); }
private:
- base::scoped_nsobject<AvatarButtonController> controller_;
+ base::scoped_nsobject<MockAvatarButtonController> controller_;
};
TEST_F(AvatarButtonControllerTest, GenericButtonShown) {
@@ -104,3 +129,27 @@ TEST_F(AvatarButtonControllerTest, DoubleOpen) {
[menu close];
EXPECT_FALSE([controller() menuController]);
}
+
+TEST_F(AvatarButtonControllerTest, TitleColor) {
+ // Create a second profile, to force the button to display the profile name.
+ testing_profile_manager()->CreateTestingProfile("batman");
+
+ // Set the frame color to be not dark. The button's title color should be
+ // black.
+ [controller() setIsFrameDark:NO];
+ [controller() updateAvatarButtonAndLayoutParent:NO];
+ NSColor* titleColor =
+ [[button() attributedTitle] attribute:NSForegroundColorAttributeName
+ atIndex:0
+ effectiveRange:nil];
+ DCHECK_EQ(titleColor, [NSColor blackColor]);
+
+ // Set the frame color to be dark. The button's title color should be white.
+ [controller() setIsFrameDark:YES];
+ [controller() updateAvatarButtonAndLayoutParent:NO];
+ titleColor =
+ [[button() attributedTitle] attribute:NSForegroundColorAttributeName
+ atIndex:0
+ effectiveRange:nil];
+ DCHECK_EQ(titleColor, [NSColor whiteColor]);
+}
« no previous file with comments | « chrome/browser/ui/cocoa/profiles/avatar_button_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698