OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #include "chrome/browser/ui/cocoa/circular_activity_indicator_view.h" | |
6 | |
7 #include "base/mac/bind_objc_block.h" | |
8 #include "base/mac/foundation_util.h" | |
9 #include "base/time/time.h" | |
10 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | |
groby-ooo-7-16
2015/03/30 23:42:07
You probably want ui/gfx/test/ui_cocoa_test_helper
shrike
2015/03/31 07:05:53
Acknowledged.
| |
11 #import "chrome/browser/ui/cocoa/circular_activity_indicator_view.h" | |
12 #include "chrome/browser/ui/cocoa/run_loop_testing.h" | |
13 | |
14 typedef CocoaTest CircularActivityIndicatorViewTest; | |
15 | |
16 @interface TestCircularActivityIndicatorView : CircularActivityIndicatorView | |
17 | |
18 - (BOOL)is_animating; | |
19 | |
20 @end | |
21 | |
22 @implementation TestCircularActivityIndicatorView | |
23 | |
24 - (BOOL)is_animating | |
groby-ooo-7-16
2015/03/30 23:42:07
Wouldn't @property BOOL is_animating; auto-synthes
shrike
2015/03/31 07:05:53
I don't think it's declared to do so. In general t
| |
25 { | |
26 return is_animating_; | |
27 } | |
28 | |
29 @end | |
30 | |
groby-ooo-7-16
2015/03/30 23:42:07
Customarily, unit tests for views have a a fixture
shrike
2015/03/31 07:05:53
Acknowledged.
| |
31 | |
32 TEST_F(CircularActivityIndicatorViewTest, StopAnimationOnMiniaturize) { | |
33 CGRect frame = NSMakeRect(0.0, 0.0, 100.0, 100.0); | |
34 NSWindow* test_window = | |
groby-ooo-7-16
2015/03/30 23:42:07
If you have a ui::CocoaTest, just call test_window
shrike
2015/03/31 07:05:54
Acknowledged.
| |
35 [[NSWindow alloc] initWithContentRect:frame | |
36 styleMask:NSClosableWindowMask | | |
37 NSMiniaturizableWindowMask | | |
38 NSResizableWindowMask | |
39 backing:NSBackingStoreBuffered | |
40 defer:NO]; | |
41 frame = NSMakeRect(10.0, 10.0, 16.0, 16.0); | |
42 TestCircularActivityIndicatorView* test_view = | |
groby-ooo-7-16
2015/03/30 23:42:07
scoped_nsobject, please. Chromium tries to do most
shrike
2015/03/31 07:05:54
Acknowledged.
| |
43 [[TestCircularActivityIndicatorView alloc] initWithFrame:frame]; | |
44 | |
45 EXPECT_FALSE([test_view is_animating]); | |
46 | |
47 [[test_window contentView] addSubview:test_view]; | |
48 | |
groby-ooo-7-16
2015/03/30 23:42:07
nit: I'd kill the empty spaces between changes and
shrike
2015/03/31 07:05:54
Acknowledged.
| |
49 EXPECT_TRUE([test_view is_animating]); | |
50 | |
51 [test_window makeKeyAndOrderFront:nil]; | |
52 | |
53 EXPECT_TRUE([test_view is_animating]); | |
54 | |
55 [test_window miniaturize:nil]; | |
56 | |
57 EXPECT_FALSE([test_view is_animating]); | |
58 | |
59 [test_window deminiaturize:nil]; | |
60 | |
61 EXPECT_TRUE([test_view is_animating]); | |
62 | |
63 [test_view removeFromSuperview]; | |
64 | |
65 EXPECT_FALSE([test_view is_animating]); | |
66 | |
67 [test_view release]; | |
68 [test_window orderOut:nil]; | |
groby-ooo-7-16
2015/03/30 23:42:07
No need to orderOut
shrike
2015/03/31 07:05:54
Done.
| |
69 [test_window release]; | |
70 } | |
71 | |
72 TEST_F(CircularActivityIndicatorViewTest, StopAnimationOnHidden) { | |
73 CGRect frame = NSMakeRect(0.0, 0.0, 100.0, 100.0); | |
74 NSWindow* test_window = | |
75 [[NSWindow alloc] initWithContentRect:frame | |
76 styleMask:NSClosableWindowMask | | |
77 NSMiniaturizableWindowMask | | |
78 NSResizableWindowMask | |
79 backing:NSBackingStoreBuffered | |
80 defer:NO]; | |
81 frame = NSMakeRect(10.0, 10.0, 16.0, 16.0); | |
82 TestCircularActivityIndicatorView* test_view = | |
83 [[TestCircularActivityIndicatorView alloc] initWithFrame:frame]; | |
84 | |
85 EXPECT_FALSE([test_view is_animating]); | |
86 | |
87 [[test_window contentView] addSubview:test_view]; | |
88 | |
89 EXPECT_TRUE([test_view is_animating]); | |
90 | |
91 [test_window makeKeyAndOrderFront:nil]; | |
92 | |
93 EXPECT_TRUE([test_view is_animating]); | |
94 | |
95 [test_view setHidden:YES]; | |
96 | |
97 EXPECT_FALSE([test_view is_animating]); | |
98 | |
99 [test_view setHidden:NO]; | |
100 | |
101 EXPECT_TRUE([test_view is_animating]); | |
102 | |
103 [test_view removeFromSuperview]; | |
104 | |
105 EXPECT_FALSE([test_view is_animating]); | |
106 | |
107 [test_view release]; | |
108 [test_window orderOut:nil]; | |
109 [test_window release]; | |
110 } | |
111 | |
OLD | NEW |