Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / spinner_view_unittest.mm
blob3f73c28c3e97c8c40cf63d9b92c8f054504a60cd
1 // Copyright (c) 2015 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 #include "chrome/browser/ui/cocoa/spinner_view.h"
7 #import "ui/gfx/test/ui_cocoa_test_helper.h"
9 @interface SpinnerView(ExposedForTesting)
11 - (BOOL)is_animating;
13 @end
15 @implementation SpinnerView(ExposedForTesting)
17 - (BOOL)is_animating
19   return is_animating_;
22 @end
24 namespace {
26   class SpinnerViewTest : public ui::CocoaTest {
27   public:
28     SpinnerViewTest() {
29       CGRect frame = NSMakeRect(0.0, 0.0, 16.0, 16.0);
30       view_.reset([[SpinnerView alloc] initWithFrame:frame]);
31       [[test_window() contentView] addSubview:view_];
32     }
34     base::scoped_nsobject<SpinnerView> view_;
35   };
37   TEST_VIEW(SpinnerViewTest, view_)
39   TEST_F(SpinnerViewTest, StopAnimationOnMiniaturize) {
40     EXPECT_TRUE([view_ is_animating]);
42     [test_window() miniaturize:nil];
43     EXPECT_FALSE([view_ is_animating]);
45     [test_window() deminiaturize:nil];
46     EXPECT_TRUE([view_ is_animating]);
47   }
49   TEST_F(SpinnerViewTest,
50          StopAnimationOnRemoveFromSuperview) {
51     EXPECT_TRUE([view_ is_animating]);
53     [view_ removeFromSuperview];
54     EXPECT_FALSE([view_ is_animating]);
56     [[test_window() contentView] addSubview:view_];
57     EXPECT_TRUE([view_ is_animating]);
58   }
60   TEST_F(SpinnerViewTest, StopAnimationOnHidden) {
61     EXPECT_TRUE([view_ is_animating]);
63     [view_ setHidden:YES];
64     EXPECT_FALSE([view_ is_animating]);
66     [view_ setHidden:NO];
67     EXPECT_TRUE([view_ is_animating]);
68   }