| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/background_gradient_view.h" | 8 #import "chrome/browser/ui/cocoa/background_gradient_view.h" |
| 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
| 12 | 12 |
| 13 // Since BackgroundGradientView doesn't do any drawing by default, we | 13 // Since BackgroundGradientView doesn't do any drawing by default, we |
| 14 // create a subclass to call its draw method for us. | 14 // create a subclass to call its draw method for us. |
| 15 @interface BackgroundGradientSubClassTest : BackgroundGradientView { | 15 @interface BackgroundGradientSubClassTest : BackgroundGradientView { |
| 16 BOOL backgroundIsOpaque; | 16 BOOL backgroundIsOpaque; |
| 17 } | 17 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 @end | 31 @end |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 class BackgroundGradientViewTest : public CocoaTest { | 35 class BackgroundGradientViewTest : public CocoaTest { |
| 36 public: | 36 public: |
| 37 BackgroundGradientViewTest() { | 37 BackgroundGradientViewTest() { |
| 38 NSRect frame = NSMakeRect(0, 0, 100, 30); | 38 NSRect frame = NSMakeRect(0, 0, 100, 30); |
| 39 scoped_nsobject<BackgroundGradientSubClassTest> view; | 39 base::scoped_nsobject<BackgroundGradientSubClassTest> view; |
| 40 view.reset([[BackgroundGradientSubClassTest alloc] initWithFrame:frame]); | 40 view.reset([[BackgroundGradientSubClassTest alloc] initWithFrame:frame]); |
| 41 view_ = view.get(); | 41 view_ = view.get(); |
| 42 [[test_window() contentView] addSubview:view_]; | 42 [[test_window() contentView] addSubview:view_]; |
| 43 } | 43 } |
| 44 | 44 |
| 45 BackgroundGradientSubClassTest* view_; | 45 BackgroundGradientSubClassTest* view_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 TEST_VIEW(BackgroundGradientViewTest, view_) | 48 TEST_VIEW(BackgroundGradientViewTest, view_) |
| 49 | 49 |
| 50 // Test drawing, mostly to ensure nothing leaks or crashes. | 50 // Test drawing, mostly to ensure nothing leaks or crashes. |
| 51 TEST_F(BackgroundGradientViewTest, DisplayWithDivider) { | 51 TEST_F(BackgroundGradientViewTest, DisplayWithDivider) { |
| 52 [view_ setShowsDivider:YES]; | 52 [view_ setShowsDivider:YES]; |
| 53 [view_ setBackgroundIsOpaque:YES]; | 53 [view_ setBackgroundIsOpaque:YES]; |
| 54 [view_ display]; | 54 [view_ display]; |
| 55 [view_ setBackgroundIsOpaque:NO]; | 55 [view_ setBackgroundIsOpaque:NO]; |
| 56 [view_ display]; | 56 [view_ display]; |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| OLD | NEW |