| 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/mac/scoped_nsobject.h" |
| 8 #include "chrome/browser/themes/theme_properties.h" | 8 #include "chrome/browser/themes/theme_properties.h" |
| 9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" | 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" |
| 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 12 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 13 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "testing/platform_test.h" | 16 #include "testing/platform_test.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 - (BOOL)isAnimatingBetweenState:(BookmarkBar::State)fromState | 87 - (BOOL)isAnimatingBetweenState:(BookmarkBar::State)fromState |
| 88 andState:(BookmarkBar::State)toState { return NO; } | 88 andState:(BookmarkBar::State)toState { return NO; } |
| 89 - (CGFloat)detachedMorphProgress { return 1; } | 89 - (CGFloat)detachedMorphProgress { return 1; } |
| 90 @end | 90 @end |
| 91 | 91 |
| 92 class BookmarkBarToolbarViewTest : public CocoaTest { | 92 class BookmarkBarToolbarViewTest : public CocoaTest { |
| 93 public: | 93 public: |
| 94 BookmarkBarToolbarViewTest() { | 94 BookmarkBarToolbarViewTest() { |
| 95 controller_.reset([[DrawDetachedBarFakeController alloc] init]); | 95 controller_.reset([[DrawDetachedBarFakeController alloc] init]); |
| 96 NSRect frame = NSMakeRect(0, 0, 400, 40); | 96 NSRect frame = NSMakeRect(0, 0, 400, 40); |
| 97 scoped_nsobject<BookmarkBarToolbarView> view( | 97 base::scoped_nsobject<BookmarkBarToolbarView> view( |
| 98 [[BookmarkBarToolbarView alloc] initWithFrame:frame]); | 98 [[BookmarkBarToolbarView alloc] initWithFrame:frame]); |
| 99 view_ = view.get(); | 99 view_ = view.get(); |
| 100 [[test_window() contentView] addSubview:view_]; | 100 [[test_window() contentView] addSubview:view_]; |
| 101 [view_ setController:controller_.get()]; | 101 [view_ setController:controller_.get()]; |
| 102 } | 102 } |
| 103 | 103 |
| 104 scoped_nsobject<DrawDetachedBarFakeController> controller_; | 104 base::scoped_nsobject<DrawDetachedBarFakeController> controller_; |
| 105 BookmarkBarToolbarView* view_; | 105 BookmarkBarToolbarView* view_; |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 TEST_VIEW(BookmarkBarToolbarViewTest, view_) | 108 TEST_VIEW(BookmarkBarToolbarViewTest, view_) |
| 109 | 109 |
| 110 // Test drawing, mostly to ensure nothing leaks or crashes. | 110 // Test drawing, mostly to ensure nothing leaks or crashes. |
| 111 TEST_F(BookmarkBarToolbarViewTest, DisplayAsNormalBar) { | 111 TEST_F(BookmarkBarToolbarViewTest, DisplayAsNormalBar) { |
| 112 [controller_.get() setState:BookmarkBar::SHOW]; | 112 [controller_.get() setState:BookmarkBar::SHOW]; |
| 113 [view_ display]; | 113 [view_ display]; |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Actions used in DisplayAsDetachedBarWithBgImage. | 116 // Actions used in DisplayAsDetachedBarWithBgImage. |
| 117 ACTION(SetBackgroundTiling) { | 117 ACTION(SetBackgroundTiling) { |
| 118 *arg1 = ThemeProperties::NO_REPEAT; | 118 *arg1 = ThemeProperties::NO_REPEAT; |
| 119 return true; | 119 return true; |
| 120 } | 120 } |
| 121 | 121 |
| 122 ACTION(SetAlignLeft) { | 122 ACTION(SetAlignLeft) { |
| 123 *arg1 = ThemeProperties::ALIGN_LEFT; | 123 *arg1 = ThemeProperties::ALIGN_LEFT; |
| 124 return true; | 124 return true; |
| 125 } | 125 } |
| 126 | 126 |
| 127 // TODO(viettrungluu): write more unit tests, especially after my refactoring. | 127 // TODO(viettrungluu): write more unit tests, especially after my refactoring. |
| OLD | NEW |