OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #import "base/mac/scoped_nsobject.h" | 5 #import "base/mac/scoped_nsobject.h" |
6 #include "chrome/browser/ui/cocoa/download/download_shelf_mac.h" | 6 #include "chrome/browser/ui/cocoa/download/download_shelf_mac.h" |
7 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" | 7 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "testing/platform_test.h" | 9 #include "testing/platform_test.h" |
10 | 10 |
11 // A fake implementation of DownloadShelfController. It implements only the | 11 // A fake implementation of DownloadShelfController. It implements only the |
12 // methods that DownloadShelfMac call during the tests in this file. We get this | 12 // methods that DownloadShelfMac call during the tests in this file. We get this |
13 // class into the DownloadShelfMac constructor by some questionable casting -- | 13 // class into the DownloadShelfMac constructor by some questionable casting -- |
14 // Objective C is a dynamic language, so we pretend that's ok. | 14 // Objective C is a dynamic language, so we pretend that's ok. |
15 | 15 |
16 @interface FakeDownloadShelfController : NSObject { | 16 @interface FakeDownloadShelfController : NSObject { |
17 @public | 17 @public |
18 int callCountIsVisible; | 18 int callCountIsVisible; |
19 int callCountShow; | 19 int callCountShow; |
20 int callCountHide; | 20 int callCountHide; |
21 int callCountCloseWithUserAction; | 21 int callCountCloseWithUserAction; |
22 } | 22 } |
23 | 23 |
24 - (BOOL)isVisible; | 24 - (BOOL)isVisible; |
25 - (void)showDownloadShelf:(BOOL)enable | 25 - (void)showDownloadShelf:(BOOL)enable |
26 isUserAction:(BOOL)isUserAction; | 26 isUserAction:(BOOL)isUserAction |
| 27 animate:(BOOL)animate; |
27 @end | 28 @end |
28 | 29 |
29 @implementation FakeDownloadShelfController | 30 @implementation FakeDownloadShelfController |
30 | 31 |
31 - (BOOL)isVisible { | 32 - (BOOL)isVisible { |
32 ++callCountIsVisible; | 33 ++callCountIsVisible; |
33 return YES; | 34 return YES; |
34 } | 35 } |
35 | 36 |
36 - (void)showDownloadShelf:(BOOL)enable | 37 - (void)showDownloadShelf:(BOOL)enable |
37 isUserAction:(BOOL)isUserAction { | 38 isUserAction:(BOOL)isUserAction |
| 39 animate:(BOOL)animate { |
38 if (enable) | 40 if (enable) |
39 ++callCountShow; | 41 ++callCountShow; |
40 else | 42 else |
41 ++callCountHide; | 43 ++callCountHide; |
42 if (isUserAction && !enable) | 44 if (isUserAction && !enable) |
43 ++callCountCloseWithUserAction; | 45 ++callCountCloseWithUserAction; |
44 } | 46 } |
45 | 47 |
46 @end | 48 @end |
47 | 49 |
(...skipping 14 matching lines...) Expand all Loading... |
62 // Also make sure the DownloadShelfMacTest constructor doesn't crash. | 64 // Also make sure the DownloadShelfMacTest constructor doesn't crash. |
63 DownloadShelfMac shelf(browser(), | 65 DownloadShelfMac shelf(browser(), |
64 (DownloadShelfController*)shelf_controller_.get()); | 66 (DownloadShelfController*)shelf_controller_.get()); |
65 EXPECT_EQ(0, shelf_controller_.get()->callCountShow); | 67 EXPECT_EQ(0, shelf_controller_.get()->callCountShow); |
66 } | 68 } |
67 | 69 |
68 TEST_F(DownloadShelfMacTest, ForwardsShow) { | 70 TEST_F(DownloadShelfMacTest, ForwardsShow) { |
69 DownloadShelfMac shelf(browser(), | 71 DownloadShelfMac shelf(browser(), |
70 (DownloadShelfController*)shelf_controller_.get()); | 72 (DownloadShelfController*)shelf_controller_.get()); |
71 EXPECT_EQ(0, shelf_controller_.get()->callCountShow); | 73 EXPECT_EQ(0, shelf_controller_.get()->callCountShow); |
72 shelf.Show(); | 74 shelf.Open(); |
73 EXPECT_EQ(1, shelf_controller_.get()->callCountShow); | 75 EXPECT_EQ(1, shelf_controller_.get()->callCountShow); |
74 } | 76 } |
75 | 77 |
76 TEST_F(DownloadShelfMacTest, ForwardsHide) { | 78 TEST_F(DownloadShelfMacTest, ForwardsHide) { |
77 DownloadShelfMac shelf(browser(), | 79 DownloadShelfMac shelf(browser(), |
78 (DownloadShelfController*)shelf_controller_.get()); | 80 (DownloadShelfController*)shelf_controller_.get()); |
79 EXPECT_EQ(0, shelf_controller_.get()->callCountHide); | 81 EXPECT_EQ(0, shelf_controller_.get()->callCountHide); |
80 shelf.Close(DownloadShelf::AUTOMATIC); | 82 shelf.Close(DownloadShelf::AUTOMATIC); |
81 EXPECT_EQ(1, shelf_controller_.get()->callCountHide); | 83 EXPECT_EQ(1, shelf_controller_.get()->callCountHide); |
82 EXPECT_EQ(0, shelf_controller_.get()->callCountCloseWithUserAction); | 84 EXPECT_EQ(0, shelf_controller_.get()->callCountCloseWithUserAction); |
(...skipping 10 matching lines...) Expand all Loading... |
93 | 95 |
94 TEST_F(DownloadShelfMacTest, ForwardsIsShowing) { | 96 TEST_F(DownloadShelfMacTest, ForwardsIsShowing) { |
95 DownloadShelfMac shelf(browser(), | 97 DownloadShelfMac shelf(browser(), |
96 (DownloadShelfController*)shelf_controller_.get()); | 98 (DownloadShelfController*)shelf_controller_.get()); |
97 EXPECT_EQ(0, shelf_controller_.get()->callCountIsVisible); | 99 EXPECT_EQ(0, shelf_controller_.get()->callCountIsVisible); |
98 shelf.IsShowing(); | 100 shelf.IsShowing(); |
99 EXPECT_EQ(1, shelf_controller_.get()->callCountIsVisible); | 101 EXPECT_EQ(1, shelf_controller_.get()->callCountIsVisible); |
100 } | 102 } |
101 | 103 |
102 } // namespace | 104 } // namespace |
OLD | NEW |