diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 22:33:14 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-20 22:33:14 +0000 |
commit | 60123ad4520e5561950d5cc949e1a0451abd4dcc (patch) | |
tree | 68035b12a4d0b9b975e87b871c0bd95f083391b0 /chrome/browser/cocoa/bookmark_bar_controller_unittest.mm | |
parent | 6e948a40ee9134cfba48eb6d007378a4f4c11a8d (diff) | |
download | chromium_src-60123ad4520e5561950d5cc949e1a0451abd4dcc.zip chromium_src-60123ad4520e5561950d5cc949e1a0451abd4dcc.tar.gz chromium_src-60123ad4520e5561950d5cc949e1a0451abd4dcc.tar.bz2 |
Apply theme color to bookmark button text.
BUG=http://crbug.com/17608
TEST=Add some bookmarks (you must use both folders and marks). Apply
a theme and make sure theme color applies bookmark button text for all
buttons (including "Other bookmarks"). Create new window and make
sure bookmark buttons still fine in new window. Quit and restart
Chrome. Make sure theme color still applied to bookmark button text
in the same way as before quitting (e.g. same color and still applies
to all). Change theme 1 more time and verify color.
Review URL: http://codereview.chromium.org/424004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32690 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bookmark_bar_controller_unittest.mm')
-rw-r--r-- | chrome/browser/cocoa/bookmark_bar_controller_unittest.mm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm index 8c14dee..91c9fb4 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm @@ -79,6 +79,27 @@ @end +@interface FakeTheme : GTMTheme { + scoped_nsobject<NSColor> color_; +} +@end + +@implementation FakeTheme +- (id)initWithColor:(NSColor*)color { + if ((self = [super init])) { + color_.reset([color retain]); + } + return self; +} + +- (NSColor*)textColorForStyle:(GTMThemeStyle)style + state:(GTMThemeState)state { + return color_.get(); +} +@end + + + namespace { static const int kContentAreaHeight = 500; @@ -847,6 +868,31 @@ TEST_F(BookmarkBarControllerTest, TestDragButton) { EXPECT_TRUE([[[[bar_ buttons] objectAtIndex:2] title] isEqual:@"a"]); } +// Fake a theme with colored text. Apply it and make sure bookmark +// buttons have the same colored text. Repeat more than once. +TEST_F(BookmarkBarControllerTest, TestThemedButton) { + BookmarkModel* model = helper_.profile()->GetBookmarkModel(); + model->SetURLStarred(GURL("http://www.foo.com"), L"small", true); + BookmarkButton* button = [[bar_ buttons] objectAtIndex:0]; + EXPECT_TRUE(button); + + NSArray* colors = [NSArray arrayWithObjects:[NSColor redColor], + [NSColor blueColor], + nil]; + for (NSColor* color in colors) { + scoped_nsobject<FakeTheme> theme([[FakeTheme alloc] initWithColor:color]); + [bar_ updateTheme:theme.get()]; + NSAttributedString* astr = [button attributedTitle]; + EXPECT_TRUE(astr); + EXPECT_TRUE([[astr string] isEqual:@"small"]); + // Pick a char in the middle to test (index 3) + NSDictionary* attributes = [astr attributesAtIndex:3 effectiveRange:NULL]; + NSColor* newColor = + [attributes objectForKey:NSForegroundColorAttributeName]; + EXPECT_TRUE([newColor isEqual:color]); + } +} + // TODO(viettrungluu): figure out how to test animations. } // namespace |