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

Side by Side Diff: chrome_frame/external_tab_test.cc

Issue 8555001: base::Bind: Convert chrome_frame/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win-dies. Created 9 years, 1 month 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_frame/custom_sync_call_context.h ('k') | chrome_frame/task_marshaller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/location.h"
6 #include "base/task.h"
7 #include "base/threading/thread.h"
8 #include "chrome_frame/external_tab.h" 5 #include "chrome_frame/external_tab.h"
9 6
10 // #include "base/synchronization/waitable_event.h" 7 // #include "base/synchronization/waitable_event.h"
11 8
9 #include "base/bind.h"
10 #include "base/bind_helpers.h"
11 #include "base/location.h"
12 #include "base/threading/thread.h"
12 #include "chrome/common/automation_messages.h" 13 #include "chrome/common/automation_messages.h"
13 #include "chrome_frame/navigation_constraints.h" 14 #include "chrome_frame/navigation_constraints.h"
14 #include "chrome_frame/test/chrome_frame_test_utils.h" 15 #include "chrome_frame/test/chrome_frame_test_utils.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gmock_mutant.h" 18 #include "testing/gmock_mutant.h"
18 19
19
20
21 // DISABLE_RUNNABLE_METHOD_REFCOUNT(ExternalTabProxy);
22 // DISABLE_RUNNABLE_METHOD_REFCOUNT(UIDelegate);
23 DISABLE_RUNNABLE_METHOD_REFCOUNT(ChromeProxyDelegate);
24
25 using testing::StrictMock; 20 using testing::StrictMock;
26 using testing::_; 21 using testing::_;
27 using testing::Invoke; 22 using testing::Invoke;
28 using testing::InvokeWithoutArgs; 23 using testing::InvokeWithoutArgs;
29 using testing::CreateFunctor; 24 using testing::CreateFunctor;
30 using testing::Return; 25 using testing::Return;
31 using testing::DoAll; 26 using testing::DoAll;
32 using testing::Field; 27 using testing::Field;
33 using chrome_frame_test::TimedMsgLoop; 28 using chrome_frame_test::TimedMsgLoop;
34 29
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 struct AsyncEventCreator { 97 struct AsyncEventCreator {
103 public: 98 public:
104 explicit AsyncEventCreator(ChromeProxyDelegate* delegate) 99 explicit AsyncEventCreator(ChromeProxyDelegate* delegate)
105 : delegate_(delegate), ipc_thread_("ipc") { 100 : delegate_(delegate), ipc_thread_("ipc") {
106 base::Thread::Options options(MessageLoop::TYPE_IO, 0); 101 base::Thread::Options options(MessageLoop::TYPE_IO, 0);
107 ipc_thread_.StartWithOptions(options); 102 ipc_thread_.StartWithOptions(options);
108 ipc_loop_ = ipc_thread_.message_loop(); 103 ipc_loop_ = ipc_thread_.message_loop();
109 } 104 }
110 105
111 void Fire_Connected(ChromeProxy* proxy, base::TimeDelta delay) { 106 void Fire_Connected(ChromeProxy* proxy, base::TimeDelta delay) {
112 ipc_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod(delegate_, 107 ipc_loop_->PostDelayedTask(
113 &ChromeProxyDelegate::Connected, proxy), delay.InMilliseconds()); 108 FROM_HERE,
109 base::Bind(&ChromeProxyDelegate::Connected, base::Unretained(delegate_),
110 proxy),
111 delay.InMilliseconds());
114 } 112 }
115 113
116 void Fire_PeerLost(ChromeProxy* proxy, 114 void Fire_PeerLost(ChromeProxy* proxy,
117 ChromeProxyDelegate::DisconnectReason reason, base::TimeDelta delay) { 115 ChromeProxyDelegate::DisconnectReason reason, base::TimeDelta delay) {
118 ipc_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod(delegate_, 116 ipc_loop_->PostDelayedTask(
119 &ChromeProxyDelegate::PeerLost, proxy, reason), delay.InMilliseconds()); 117 FROM_HERE,
118 base::Bind(&ChromeProxyDelegate::PeerLost, base::Unretained(delegate_),
119 proxy, reason),
120 delay.InMilliseconds());
120 } 121 }
121 122
122 void Fire_Disconnected(base::TimeDelta delay) { 123 void Fire_Disconnected(base::TimeDelta delay) {
123 ipc_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod(delegate_, 124 ipc_loop_->PostDelayedTask(
124 &ChromeProxyDelegate::Disconnected), delay.InMilliseconds()); 125 FROM_HERE,
126 base::Bind(&ChromeProxyDelegate::Disconnected,
127 base::Unretained(delegate_)),
128 delay.InMilliseconds());
125 } 129 }
126 130
127 void Fire_CompletedCreateTab(bool success, HWND chrome_wnd, HWND tab_window, 131 void Fire_CompletedCreateTab(bool success, HWND chrome_wnd, HWND tab_window,
128 int tab_handle, int session_id, 132 int tab_handle, int session_id,
129 base::TimeDelta delay) { 133 base::TimeDelta delay) {
130 ipc_loop_->PostDelayedTask(FROM_HERE, NewRunnableMethod(delegate_, 134 ipc_loop_->PostDelayedTask(
131 &ChromeProxyDelegate::Completed_CreateTab, success, chrome_wnd, 135 FROM_HERE,
132 tab_window, tab_handle, session_id), delay.InMilliseconds()); 136 base::Bind(&ChromeProxyDelegate::Completed_CreateTab,
137 base::Unretained(delegate_), success, chrome_wnd, tab_window,
138 tab_handle, session_id),
139 delay.InMilliseconds());
133 } 140 }
134 141
135 private: 142 private:
136 ChromeProxyDelegate* delegate_; 143 ChromeProxyDelegate* delegate_;
137 base::Thread ipc_thread_; 144 base::Thread ipc_thread_;
138 MessageLoop* ipc_loop_; 145 MessageLoop* ipc_loop_;
139 }; 146 };
140 147
141 // We may want the same test with 'real' proxy and mock 'proxy traits'. 148 // We may want the same test with 'real' proxy and mock 'proxy traits'.
142 TEST(ExternalTabProxy, CancelledCreateTab) { 149 TEST(ExternalTabProxy, CancelledCreateTab) {
(...skipping 27 matching lines...) Expand all
170 CreateTabParams tab_params; 177 CreateTabParams tab_params;
171 tab_params.is_incognito = true; 178 tab_params.is_incognito = true;
172 tab_params.is_widget_mode = false; 179 tab_params.is_widget_mode = false;
173 tab_params.url = GURL("http://Xanadu.org"); 180 tab_params.url = GURL("http://Xanadu.org");
174 181
175 tab->CreateTab(tab_params, &ui_delegate); 182 tab->CreateTab(tab_params, &ui_delegate);
176 loop.RunFor(5); 183 loop.RunFor(5);
177 EXPECT_FALSE(loop.WasTimedOut()); 184 EXPECT_FALSE(loop.WasTimedOut());
178 tab.reset(); 185 tab.reset();
179 } 186 }
OLDNEW
« no previous file with comments | « chrome_frame/custom_sync_call_context.h ('k') | chrome_frame/task_marshaller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698