OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/browser_test_helper.h" | 5 #include "chrome/browser/cocoa/browser_test_helper.h" |
6 #include "chrome/browser/cocoa/cocoa_test_helper.h" | 6 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
7 #include "chrome/browser/cocoa/download_shelf_mac.h" | 7 #include "chrome/browser/cocoa/download_shelf_mac.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 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; |
(...skipping 18 matching lines...) Expand all Loading... |
38 | 38 |
39 - (IBAction)hide:(id)sender { | 39 - (IBAction)hide:(id)sender { |
40 ++callCountHide; | 40 ++callCountHide; |
41 } | 41 } |
42 | 42 |
43 @end | 43 @end |
44 | 44 |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 class DownloadShelfMacTest : public testing::Test { | 48 class DownloadShelfMacTest : public PlatformTest { |
49 | 49 |
50 virtual void SetUp() { | 50 virtual void SetUp() { |
51 shelf_controller_.reset([[FakeDownloadShelfController alloc] init]); | 51 shelf_controller_.reset([[FakeDownloadShelfController alloc] init]); |
52 } | 52 } |
53 | 53 |
54 protected: | 54 protected: |
55 scoped_nsobject<FakeDownloadShelfController> shelf_controller_; | 55 scoped_nsobject<FakeDownloadShelfController> shelf_controller_; |
56 CocoaTestHelper helper_; | 56 CocoaTestHelper helper_; |
57 BrowserTestHelper browser_helper_; | 57 BrowserTestHelper browser_helper_; |
58 }; | 58 }; |
(...skipping 23 matching lines...) Expand all Loading... |
82 | 82 |
83 TEST_F(DownloadShelfMacTest, ForwardsIsShowing) { | 83 TEST_F(DownloadShelfMacTest, ForwardsIsShowing) { |
84 DownloadShelfMac shelf(browser_helper_.browser(), | 84 DownloadShelfMac shelf(browser_helper_.browser(), |
85 (DownloadShelfController*)shelf_controller_.get()); | 85 (DownloadShelfController*)shelf_controller_.get()); |
86 EXPECT_EQ(0, shelf_controller_.get()->callCountIsVisible); | 86 EXPECT_EQ(0, shelf_controller_.get()->callCountIsVisible); |
87 shelf.IsShowing(); | 87 shelf.IsShowing(); |
88 EXPECT_EQ(1, shelf_controller_.get()->callCountIsVisible); | 88 EXPECT_EQ(1, shelf_controller_.get()->callCountIsVisible); |
89 } | 89 } |
90 | 90 |
91 } // namespace | 91 } // namespace |
OLD | NEW |