Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / background_gradient_view_unittest.mm
blob3a45559d7522d1f1992fb122b3b59c9728768137
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.
5 #import <Cocoa/Cocoa.h>
7 #include "base/mac/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"
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
18 @implementation BackgroundGradientSubClassTest
20 - (void)drawRect:(NSRect)dirtyRect {
21   [self drawBackground:dirtyRect];
24 @end
26 namespace {
28 class BackgroundGradientViewTest : public CocoaTest {
29  public:
30   BackgroundGradientViewTest() {
31     NSRect frame = NSMakeRect(0, 0, 100, 30);
32     base::scoped_nsobject<BackgroundGradientSubClassTest> view(
33         [[BackgroundGradientSubClassTest alloc] initWithFrame:frame]);
34     view_ = view.get();
35     [[test_window() contentView] addSubview:view_];
36   }
38   BackgroundGradientSubClassTest* view_;
41 TEST_VIEW(BackgroundGradientViewTest, view_)
43 // Test drawing, mostly to ensure nothing leaks or crashes.
44 TEST_F(BackgroundGradientViewTest, DisplayWithDivider) {
45   [view_ setShowsDivider:YES];
46   [view_ display];
49 }  // namespace