Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: chrome/browser/cocoa/download_shelf_mac_unittest.mm

Issue 93129: Initial download shelf on OS X.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: fix download_uitest Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/download_shelf_mac.mm ('k') | chrome/browser/cocoa/download_shelf_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/chrome/browser/cocoa/find_bar_bridge_unittest.mm:r69-2775
Added: svn:eol-style
+ LF
OLDNEW
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/find_bar_controller.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/find_bar_bridge.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
10
11 // A fake implementation of DownloadShelfController. It implements only the
12 // methods that DownloadShelfMac call during the tests in this file. We get this
13 // class into the DownloadShelfMac constructor by some questionable casting --
14 // Objective C is a dynamic language, so we pretend that's ok.
15
16 @interface FakeDownloadShelfController : NSObject {
17 @public
18 int callCountIsVisible;
19 int callCountShow;
20 int callCountHide;
21 }
22
23 - (BOOL)isVisible;
24 - (IBAction)show:(id)sender;
25 - (IBAction)hide:(id)sender;
26 @end
27
28 @implementation FakeDownloadShelfController
29
30 - (BOOL)isVisible {
31 ++callCountIsVisible;
32 return YES;
33 }
34
35 - (IBAction)show:(id)sender {
36 ++callCountShow;
37 }
38
39 - (IBAction)hide:(id)sender {
40 ++callCountHide;
41 }
42
43 @end
44
45
10 namespace { 46 namespace {
11 47
12 class FindBarBridgeTest : public testing::Test { 48 class DownloadShelfMacTest : public testing::Test {
49
50 virtual void SetUp() {
51 shelf_controller_.reset([[FakeDownloadShelfController alloc] init]);
52 }
53
13 protected: 54 protected:
55 scoped_nsobject<FakeDownloadShelfController> shelf_controller_;
14 CocoaTestHelper helper_; 56 CocoaTestHelper helper_;
57 BrowserTestHelper browser_helper_;
15 }; 58 };
16 59
17 TEST_F(FindBarBridgeTest, Creation) { 60 TEST_F(DownloadShelfMacTest, CreationCallsShow) {
18 // Make sure the FindBarBridge constructor doesn't crash and 61 // Also make sure the DownloadShelfMacTest constructor doesn't crash.
19 // properly initializes its FindBarCocoaController. 62 DownloadShelfMac shelf(browser_helper_.browser(),
20 FindBarBridge bridge; 63 (DownloadShelfController*)shelf_controller_.get());
21 EXPECT_TRUE(bridge.find_bar_cocoa_controller() != NULL); 64 EXPECT_EQ(1, shelf_controller_.get()->callCountShow);
22 } 65 }
23 66
24 TEST_F(FindBarBridgeTest, Accessors) { 67 TEST_F(DownloadShelfMacTest, ForwardsShow) {
25 // Get/SetFindBarController are virtual methods implemented in 68 DownloadShelfMac shelf(browser_helper_.browser(),
26 // FindBarBridge, so we test them here. 69 (DownloadShelfController*)shelf_controller_.get());
27 FindBarBridge* bridge = new FindBarBridge(); 70 EXPECT_EQ(1, shelf_controller_.get()->callCountShow);
28 FindBarController controller(bridge); // takes ownership of |bridge|. 71 shelf.Show();
29 bridge->SetFindBarController(&controller); 72 EXPECT_EQ(2, shelf_controller_.get()->callCountShow);
73 }
30 74
31 EXPECT_EQ(&controller, bridge->GetFindBarController()); 75 TEST_F(DownloadShelfMacTest, ForwardsHide) {
76 DownloadShelfMac shelf(browser_helper_.browser(),
77 (DownloadShelfController*)shelf_controller_.get());
78 EXPECT_EQ(0, shelf_controller_.get()->callCountHide);
79 shelf.Close();
80 EXPECT_EQ(1, shelf_controller_.get()->callCountHide);
32 } 81 }
82
83 TEST_F(DownloadShelfMacTest, ForwardsIsShowing) {
84 DownloadShelfMac shelf(browser_helper_.browser(),
85 (DownloadShelfController*)shelf_controller_.get());
86 EXPECT_EQ(0, shelf_controller_.get()->callCountIsVisible);
87 shelf.IsShowing();
88 EXPECT_EQ(1, shelf_controller_.get()->callCountIsVisible);
89 }
90
33 } // namespace 91 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/download_shelf_mac.mm ('k') | chrome/browser/cocoa/download_shelf_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698