| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
| 8 #include "chrome/browser/themes/theme_service.h" | 8 #include "chrome/browser/themes/theme_service.h" |
| 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" |
| 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 12 #include "grit/theme_resources.h" | 12 #include "grit/theme_resources.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
| 18 #include "ui/base/theme_provider.h" | 18 #include "ui/base/theme_provider.h" |
| 19 #include "ui/gfx/image/image_skia.h" |
| 19 | 20 |
| 20 using ::testing::_; | 21 using ::testing::_; |
| 21 using ::testing::DoAll; | 22 using ::testing::DoAll; |
| 22 using ::testing::NiceMock; | 23 using ::testing::NiceMock; |
| 23 using ::testing::Return; | 24 using ::testing::Return; |
| 24 using ::testing::SetArgumentPointee; | 25 using ::testing::SetArgumentPointee; |
| 25 | 26 |
| 26 // When testing the floating drawing, we need to have a source of theme data. | 27 // When testing the floating drawing, we need to have a source of theme data. |
| 27 class MockThemeProvider : public ui::ThemeProvider { | 28 class MockThemeProvider : public ui::ThemeProvider { |
| 28 public: | 29 public: |
| 29 // Cross platform methods | 30 // Cross platform methods |
| 30 MOCK_METHOD1(Init, void(Profile*)); | 31 MOCK_METHOD1(Init, void(Profile*)); |
| 31 MOCK_CONST_METHOD1(GetBitmapNamed, SkBitmap*(int)); | 32 MOCK_CONST_METHOD1(GetBitmapNamed, SkBitmap*(int)); |
| 33 MOCK_CONST_METHOD1(GetImageSkiaNamed, gfx::ImageSkia*(int)); |
| 32 MOCK_CONST_METHOD1(GetColor, SkColor(int)); | 34 MOCK_CONST_METHOD1(GetColor, SkColor(int)); |
| 33 MOCK_CONST_METHOD2(GetDisplayProperty, bool(int, int*)); | 35 MOCK_CONST_METHOD2(GetDisplayProperty, bool(int, int*)); |
| 34 MOCK_CONST_METHOD0(ShouldUseNativeFrame, bool()); | 36 MOCK_CONST_METHOD0(ShouldUseNativeFrame, bool()); |
| 35 MOCK_CONST_METHOD1(HasCustomImage, bool(int)); | 37 MOCK_CONST_METHOD1(HasCustomImage, bool(int)); |
| 36 MOCK_CONST_METHOD1(GetRawData, base::RefCountedMemory*(int)); | 38 MOCK_CONST_METHOD1(GetRawData, base::RefCountedMemory*(int)); |
| 37 | 39 |
| 38 // OSX stuff | 40 // OSX stuff |
| 39 MOCK_CONST_METHOD2(GetNSImageNamed, NSImage*(int, bool)); | 41 MOCK_CONST_METHOD2(GetNSImageNamed, NSImage*(int, bool)); |
| 40 MOCK_CONST_METHOD2(GetNSImageColorNamed, NSColor*(int, bool)); | 42 MOCK_CONST_METHOD2(GetNSImageColorNamed, NSColor*(int, bool)); |
| 41 MOCK_CONST_METHOD2(GetNSColor, NSColor*(int, bool)); | 43 MOCK_CONST_METHOD2(GetNSColor, NSColor*(int, bool)); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 EXPECT_CALL(provider, GetBitmapNamed(IDR_THEME_NTP_BACKGROUND)) | 185 EXPECT_CALL(provider, GetBitmapNamed(IDR_THEME_NTP_BACKGROUND)) |
| 184 .WillRepeatedly(Return(&fake_bg)); | 186 .WillRepeatedly(Return(&fake_bg)); |
| 185 | 187 |
| 186 [controller_.get() setThemeProvider:&provider]; | 188 [controller_.get() setThemeProvider:&provider]; |
| 187 [controller_.get() setCurrentTabContentsHeight:200]; | 189 [controller_.get() setCurrentTabContentsHeight:200]; |
| 188 | 190 |
| 189 [view_ display]; | 191 [view_ display]; |
| 190 } | 192 } |
| 191 | 193 |
| 192 // TODO(viettrungluu): write more unit tests, especially after my refactoring. | 194 // TODO(viettrungluu): write more unit tests, especially after my refactoring. |
| OLD | NEW |