OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/ui/cocoa/spinner_view.h" | 5 #include "chrome/browser/ui/cocoa/spinner_view.h" |
6 | 6 |
7 #import "ui/gfx/test/ui_cocoa_test_helper.h" | 7 #import "ui/gfx/test/ui_cocoa_test_helper.h" |
8 | 8 |
9 @interface SpinnerView(ExposedForTesting) | 9 @interface SpinnerView (ExposedForTesting) |
10 | 10 |
11 - (BOOL)is_animating; | 11 - (BOOL)isAnimating; |
12 | 12 |
13 @end | 13 @end |
14 | 14 |
15 @implementation SpinnerView(ExposedForTesting) | 15 @implementation SpinnerView (ExposedForTesting) |
16 | 16 |
17 - (BOOL)is_animating | 17 - (BOOL)isAnimating { |
18 { | 18 return isAnimating_; |
19 return is_animating_; | |
20 } | 19 } |
21 | 20 |
22 @end | 21 @end |
23 | 22 |
24 namespace { | 23 namespace { |
25 | 24 |
26 class SpinnerViewTest : public ui::CocoaTest { | 25 class SpinnerViewTest : public ui::CocoaTest { |
27 public: | 26 public: |
28 SpinnerViewTest() { | 27 SpinnerViewTest() { |
29 CGRect frame = NSMakeRect(0.0, 0.0, 16.0, 16.0); | 28 CGRect frame = NSMakeRect(0.0, 0.0, 16.0, 16.0); |
30 view_.reset([[SpinnerView alloc] initWithFrame:frame]); | 29 view_.reset([[SpinnerView alloc] initWithFrame:frame]); |
31 [[test_window() contentView] addSubview:view_]; | 30 [[test_window() contentView] addSubview:view_]; |
32 } | |
33 | |
34 base::scoped_nsobject<SpinnerView> view_; | |
35 }; | |
36 | |
37 TEST_VIEW(SpinnerViewTest, view_) | |
38 | |
39 TEST_F(SpinnerViewTest, StopAnimationOnMiniaturize) { | |
40 EXPECT_TRUE([view_ is_animating]); | |
41 | |
42 [test_window() miniaturize:nil]; | |
43 EXPECT_FALSE([view_ is_animating]); | |
44 | |
45 [test_window() deminiaturize:nil]; | |
46 EXPECT_TRUE([view_ is_animating]); | |
47 } | 31 } |
48 | 32 |
49 TEST_F(SpinnerViewTest, | 33 base::scoped_nsobject<SpinnerView> view_; |
50 StopAnimationOnRemoveFromSuperview) { | 34 }; |
51 EXPECT_TRUE([view_ is_animating]); | |
52 | 35 |
53 [view_ removeFromSuperview]; | 36 TEST_VIEW(SpinnerViewTest, view_) |
54 EXPECT_FALSE([view_ is_animating]); | |
55 | 37 |
56 [[test_window() contentView] addSubview:view_]; | 38 TEST_F(SpinnerViewTest, StopAnimationOnMiniaturize) { |
57 EXPECT_TRUE([view_ is_animating]); | 39 EXPECT_TRUE([view_ isAnimating]); |
58 } | |
59 | 40 |
60 TEST_F(SpinnerViewTest, StopAnimationOnHidden) { | 41 [test_window() miniaturize:nil]; |
61 EXPECT_TRUE([view_ is_animating]); | 42 EXPECT_FALSE([view_ isAnimating]); |
62 | 43 |
63 [view_ setHidden:YES]; | 44 [test_window() deminiaturize:nil]; |
64 EXPECT_FALSE([view_ is_animating]); | 45 EXPECT_TRUE([view_ isAnimating]); |
65 | |
66 [view_ setHidden:NO]; | |
67 EXPECT_TRUE([view_ is_animating]); | |
68 } | |
69 } | 46 } |
70 | 47 |
| 48 TEST_F(SpinnerViewTest, |
| 49 StopAnimationOnRemoveFromSuperview) { |
| 50 EXPECT_TRUE([view_ isAnimating]); |
| 51 |
| 52 [view_ removeFromSuperview]; |
| 53 EXPECT_FALSE([view_ isAnimating]); |
| 54 |
| 55 [[test_window() contentView] addSubview:view_]; |
| 56 EXPECT_TRUE([view_ isAnimating]); |
| 57 } |
| 58 |
| 59 TEST_F(SpinnerViewTest, StopAnimationOnHidden) { |
| 60 EXPECT_TRUE([view_ isAnimating]); |
| 61 |
| 62 [view_ setHidden:YES]; |
| 63 EXPECT_FALSE([view_ isAnimating]); |
| 64 |
| 65 [view_ setHidden:NO]; |
| 66 EXPECT_TRUE([view_ isAnimating]); |
| 67 } |
| 68 |
| 69 } // namespace |
OLD | NEW |