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 3 // found in the LICENSE file. 4 5 #import <Cocoa/Cocoa.h> 6 7 #include "base/memory/scoped_nsobject.h" 8 #import "chrome/browser/ui/cocoa/background_gradient_view.h" 9 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/platform_test.h" 12 13 // Since BackgroundGradientView doesn't do any drawing by default, we 14 // create a subclass to call its draw method for us. 15 @interface BackgroundGradientSubClassTest : BackgroundGradientView 16 @end 17 18 @implementation BackgroundGradientSubClassTest 19 - (void)drawRect:(NSRect)rect { 20 [self drawBackground]; 21 } 22 @end 23 24 namespace { 25 26 class BackgroundGradientViewTest : public CocoaTest { 27 public: 28 BackgroundGradientViewTest() { 29 NSRect frame = NSMakeRect(0, 0, 100, 30); 30 scoped_nsobject<BackgroundGradientSubClassTest> view; 31 view.reset([[BackgroundGradientSubClassTest alloc] initWithFrame:frame]); 32 view_ = view.get(); 33 [[test_window() contentView] addSubview:view_]; 34 } 35 36 BackgroundGradientSubClassTest* view_; 37 }; 38 39 TEST_VIEW(BackgroundGradientViewTest, view_) 40 41 // Test drawing, mostly to ensure nothing leaks or crashes. 42 TEST_F(BackgroundGradientViewTest, DisplayWithDivider) { 43 [view_ setShowsDivider:YES]; 44 [view_ display]; 45 } 46 47 } // namespace 48