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

Side by Side Diff: chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged ToT Created 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/scoped_nsobject.h" 5 #include "base/memory/scoped_nsobject.h"
6 #include "base/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/notifications/balloon.h" 7 #include "chrome/browser/notifications/balloon.h"
8 #include "chrome/browser/notifications/balloon_collection.h" 8 #include "chrome/browser/notifications/balloon_collection.h"
9 #include "chrome/browser/notifications/notification.h" 9 #include "chrome/browser/notifications/notification.h"
10 #include "chrome/browser/notifications/notification_object_proxy.h" 10 #include "chrome/browser/notifications/notification_object_proxy.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" 12 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
13 #include "chrome/browser/ui/cocoa/notifications/balloon_controller.h" 13 #include "chrome/browser/ui/cocoa/notifications/balloon_controller.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "chrome/test/base/test_browser_window.h" 15 #include "chrome/test/base/test_browser_window.h"
16 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
17 #include "content/public/test/test_browser_thread.h"
18
19 using content::BrowserThread;
20 17
21 // Subclass balloon controller and mock out the initialization of the RVH. 18 // Subclass balloon controller and mock out the initialization of the RVH.
22 @interface TestBalloonController : BalloonController { 19 @interface TestBalloonController : BalloonController {
23 } 20 }
24 - (void)initializeHost; 21 - (void)initializeHost;
25 @end 22 @end
26 23
27 @implementation TestBalloonController 24 @implementation TestBalloonController
28 - (void)initializeHost {} 25 - (void)initializeHost {}
29 @end 26 @end
(...skipping 21 matching lines...) Expand all
51 virtual void OnBalloonClosed(Balloon* source) OVERRIDE {}; 48 virtual void OnBalloonClosed(Balloon* source) OVERRIDE {};
52 virtual const Balloons& GetActiveBalloons() OVERRIDE { 49 virtual const Balloons& GetActiveBalloons() OVERRIDE {
53 NOTREACHED(); 50 NOTREACHED();
54 return balloons_; 51 return balloons_;
55 } 52 }
56 private: 53 private:
57 Balloons balloons_; 54 Balloons balloons_;
58 }; 55 };
59 56
60 class BalloonControllerTest : public ChromeRenderViewHostTestHarness { 57 class BalloonControllerTest : public ChromeRenderViewHostTestHarness {
61 public: 58 virtual void SetUp() OVERRIDE {
62 BalloonControllerTest() :
63 ui_thread_(BrowserThread::UI, base::MessageLoop::current()),
64 file_user_blocking_thread_(
65 BrowserThread::FILE_USER_BLOCKING, base::MessageLoop::current()),
66 io_thread_(BrowserThread::IO, base::MessageLoop::current()) {
67 }
68
69 virtual void SetUp() {
70 ChromeRenderViewHostTestHarness::SetUp(); 59 ChromeRenderViewHostTestHarness::SetUp();
71 CocoaTest::BootstrapCocoa(); 60 CocoaTest::BootstrapCocoa();
72 profile()->CreateRequestContext(); 61 profile()->CreateRequestContext();
73 Browser::CreateParams native_params(profile(), 62 Browser::CreateParams native_params(profile(),
74 chrome::HOST_DESKTOP_TYPE_NATIVE); 63 chrome::HOST_DESKTOP_TYPE_NATIVE);
75 browser_.reset( 64 browser_.reset(
76 chrome::CreateBrowserWithTestWindowForParams(&native_params)); 65 chrome::CreateBrowserWithTestWindowForParams(&native_params));
77 collection_.reset(new MockBalloonCollection()); 66 collection_.reset(new MockBalloonCollection());
78 } 67 }
79 68
80 virtual void TearDown() { 69 virtual void TearDown() OVERRIDE {
81 collection_.reset(); 70 collection_.reset();
82 browser_.reset(); 71 browser_.reset();
83 base::MessageLoop::current()->RunUntilIdle();
84 ChromeRenderViewHostTestHarness::TearDown(); 72 ChromeRenderViewHostTestHarness::TearDown();
85 } 73 }
86 74
87 protected: 75 protected:
88 content::TestBrowserThread ui_thread_;
89 content::TestBrowserThread file_user_blocking_thread_;
90 content::TestBrowserThread io_thread_;
91 scoped_ptr<Browser> browser_; 76 scoped_ptr<Browser> browser_;
92 scoped_ptr<BalloonCollection> collection_; 77 scoped_ptr<BalloonCollection> collection_;
93 }; 78 };
94 79
95 TEST_F(BalloonControllerTest, ShowAndCloseTest) { 80 TEST_F(BalloonControllerTest, ShowAndCloseTest) {
96 Notification n(GURL("http://www.google.com"), GURL("http://www.google.com"), 81 Notification n(GURL("http://www.google.com"), GURL("http://www.google.com"),
97 ASCIIToUTF16("http://www.google.com"), string16(), 82 ASCIIToUTF16("http://www.google.com"), string16(),
98 new NotificationObjectProxy(-1, -1, -1, false)); 83 new NotificationObjectProxy(-1, -1, -1, false));
99 scoped_ptr<Balloon> balloon( 84 scoped_ptr<Balloon> balloon(
100 new Balloon(n, profile(), collection_.get())); 85 new Balloon(n, profile(), collection_.get()));
(...skipping 21 matching lines...) Expand all
122 107
123 [controller showWindow:nil]; 108 [controller showWindow:nil];
124 109
125 EXPECT_TRUE([controller desiredTotalWidth] > 100); 110 EXPECT_TRUE([controller desiredTotalWidth] > 100);
126 EXPECT_TRUE([controller desiredTotalHeight] > 100); 111 EXPECT_TRUE([controller desiredTotalHeight] > 100);
127 112
128 [controller closeBalloon:YES]; 113 [controller closeBalloon:YES];
129 } 114 }
130 115
131 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698