OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "app/theme_provider.h" | |
8 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
9 #include "chrome/browser/themes/browser_theme_provider.h" | 8 #include "chrome/browser/themes/browser_theme_provider.h" |
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" |
12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
13 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
17 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
| 18 #include "ui/base/theme_provider.h" |
19 | 19 |
20 using ::testing::_; | 20 using ::testing::_; |
21 using ::testing::DoAll; | 21 using ::testing::DoAll; |
22 using ::testing::Return; | 22 using ::testing::Return; |
23 using ::testing::SetArgumentPointee; | 23 using ::testing::SetArgumentPointee; |
24 | 24 |
25 // When testing the floating drawing, we need to have a source of theme data. | 25 // When testing the floating drawing, we need to have a source of theme data. |
26 class MockThemeProvider : public ThemeProvider { | 26 class MockThemeProvider : public ui::ThemeProvider { |
27 public: | 27 public: |
28 // Cross platform methods | 28 // Cross platform methods |
29 MOCK_METHOD1(Init, void(Profile*)); | 29 MOCK_METHOD1(Init, void(Profile*)); |
30 MOCK_CONST_METHOD1(GetBitmapNamed, SkBitmap*(int)); | 30 MOCK_CONST_METHOD1(GetBitmapNamed, SkBitmap*(int)); |
31 MOCK_CONST_METHOD1(GetColor, SkColor(int)); | 31 MOCK_CONST_METHOD1(GetColor, SkColor(int)); |
32 MOCK_CONST_METHOD2(GetDisplayProperty, bool(int, int*)); | 32 MOCK_CONST_METHOD2(GetDisplayProperty, bool(int, int*)); |
33 MOCK_CONST_METHOD0(ShouldUseNativeFrame, bool()); | 33 MOCK_CONST_METHOD0(ShouldUseNativeFrame, bool()); |
34 MOCK_CONST_METHOD1(HasCustomImage, bool(int)); | 34 MOCK_CONST_METHOD1(HasCustomImage, bool(int)); |
35 MOCK_CONST_METHOD1(GetRawData, RefCountedMemory*(int)); | 35 MOCK_CONST_METHOD1(GetRawData, RefCountedMemory*(int)); |
36 | 36 |
(...skipping 14 matching lines...) Expand all Loading... |
51 -(void)setController:(id<BookmarkBarToolbarViewController>)controller { | 51 -(void)setController:(id<BookmarkBarToolbarViewController>)controller { |
52 controller_ = controller; | 52 controller_ = controller; |
53 } | 53 } |
54 @end | 54 @end |
55 | 55 |
56 // Allows us to control which way the view is rendered. | 56 // Allows us to control which way the view is rendered. |
57 @interface DrawDetachedBarFakeController : | 57 @interface DrawDetachedBarFakeController : |
58 NSObject<BookmarkBarState, BookmarkBarToolbarViewController> { | 58 NSObject<BookmarkBarState, BookmarkBarToolbarViewController> { |
59 @private | 59 @private |
60 int currentTabContentsHeight_; | 60 int currentTabContentsHeight_; |
61 ThemeProvider* themeProvider_; | 61 ui::ThemeProvider* themeProvider_; |
62 bookmarks::VisualState visualState_; | 62 bookmarks::VisualState visualState_; |
63 } | 63 } |
64 @property (nonatomic, assign) int currentTabContentsHeight; | 64 @property (nonatomic, assign) int currentTabContentsHeight; |
65 @property (nonatomic, assign) ThemeProvider* themeProvider; | 65 @property (nonatomic, assign) ui::ThemeProvider* themeProvider; |
66 @property (nonatomic, assign) bookmarks::VisualState visualState; | 66 @property (nonatomic, assign) bookmarks::VisualState visualState; |
67 | 67 |
68 // |BookmarkBarState| protocol: | 68 // |BookmarkBarState| protocol: |
69 - (BOOL)isVisible; | 69 - (BOOL)isVisible; |
70 - (BOOL)isAnimationRunning; | 70 - (BOOL)isAnimationRunning; |
71 - (BOOL)isInState:(bookmarks::VisualState)state; | 71 - (BOOL)isInState:(bookmarks::VisualState)state; |
72 - (BOOL)isAnimatingToState:(bookmarks::VisualState)state; | 72 - (BOOL)isAnimatingToState:(bookmarks::VisualState)state; |
73 - (BOOL)isAnimatingFromState:(bookmarks::VisualState)state; | 73 - (BOOL)isAnimatingFromState:(bookmarks::VisualState)state; |
74 - (BOOL)isAnimatingFromState:(bookmarks::VisualState)fromState | 74 - (BOOL)isAnimatingFromState:(bookmarks::VisualState)fromState |
75 toState:(bookmarks::VisualState)toState; | 75 toState:(bookmarks::VisualState)toState; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 EXPECT_CALL(provider, GetBitmapNamed(IDR_THEME_NTP_BACKGROUND)) | 182 EXPECT_CALL(provider, GetBitmapNamed(IDR_THEME_NTP_BACKGROUND)) |
183 .WillRepeatedly(Return(&fake_bg)); | 183 .WillRepeatedly(Return(&fake_bg)); |
184 | 184 |
185 [controller_.get() setThemeProvider:&provider]; | 185 [controller_.get() setThemeProvider:&provider]; |
186 [controller_.get() setCurrentTabContentsHeight:200]; | 186 [controller_.get() setCurrentTabContentsHeight:200]; |
187 | 187 |
188 [view_ display]; | 188 [view_ display]; |
189 } | 189 } |
190 | 190 |
191 // TODO(viettrungluu): write more unit tests, especially after my refactoring. | 191 // TODO(viettrungluu): write more unit tests, especially after my refactoring. |
OLD | NEW |