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 #include <string> | 5 #include <string> |
6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "chrome/common/automation_messages.h" | 9 #include "chrome/common/automation_messages.h" |
10 #include "chrome_frame/cfproxy_private.h" | 10 #include "chrome_frame/cfproxy_private.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 MOCK_METHOD2(PeerLost, void(ChromeProxy*, enum DisconnectReason reason)); | 34 MOCK_METHOD2(PeerLost, void(ChromeProxy*, enum DisconnectReason reason)); |
35 MOCK_METHOD0(Disconnected, void()); | 35 MOCK_METHOD0(Disconnected, void()); |
36 MOCK_METHOD0(tab_handle, int()); | 36 MOCK_METHOD0(tab_handle, int()); |
37 | 37 |
38 MOCK_METHOD5(Completed_CreateTab, void(bool success, HWND chrome_wnd, | 38 MOCK_METHOD5(Completed_CreateTab, void(bool success, HWND chrome_wnd, |
39 HWND tab_window, int tab_handle, int session_id)); | 39 HWND tab_window, int tab_handle, int session_id)); |
40 MOCK_METHOD5(Completed_ConnectToTab, void(bool success, HWND chrome_window, | 40 MOCK_METHOD5(Completed_ConnectToTab, void(bool success, HWND chrome_window, |
41 HWND tab_window, int tab_handle, int session_id)); | 41 HWND tab_window, int tab_handle, int session_id)); |
42 MOCK_METHOD2(Completed_Navigate, void(bool success, | 42 MOCK_METHOD2(Completed_Navigate, void(bool success, |
43 enum AutomationMsg_NavigationResponseValues res)); | 43 enum AutomationMsg_NavigationResponseValues res)); |
44 MOCK_METHOD3(Completed_InstallExtension, void(bool success, | |
45 enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx)); | |
46 MOCK_METHOD3(Completed_LoadExpandedExtension, void(bool success, | |
47 enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx)); | |
48 MOCK_METHOD2(Completed_GetEnabledExtensions, void(bool success, | |
49 const std::vector<FilePath>* v)); | |
50 | 44 |
51 // Network requests from Chrome. | 45 // Network requests from Chrome. |
52 MOCK_METHOD2(Network_Start, void(int request_id, | 46 MOCK_METHOD2(Network_Start, void(int request_id, |
53 const AutomationURLRequest& request_info)); | 47 const AutomationURLRequest& request_info)); |
54 MOCK_METHOD2(Network_Read, void(int request_id, int bytes_to_read)); | 48 MOCK_METHOD2(Network_Read, void(int request_id, int bytes_to_read)); |
55 MOCK_METHOD2(Network_End, void(int request_id, | 49 MOCK_METHOD2(Network_End, void(int request_id, |
56 const net::URLRequestStatus& s)); | 50 const net::URLRequestStatus& s)); |
57 MOCK_METHOD1(Network_DownloadInHost, void(int request_id)); | 51 MOCK_METHOD1(Network_DownloadInHost, void(int request_id)); |
58 MOCK_METHOD2(GetCookies, void(const GURL& url, int cookie_id)); | 52 MOCK_METHOD2(GetCookies, void(const GURL& url, int cookie_id)); |
59 MOCK_METHOD2(SetCookie, void(const GURL& url, const std::string& cookie)); | 53 MOCK_METHOD2(SetCookie, void(const GURL& url, const std::string& cookie)); |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 base::Thread ipc("ipc"); | 330 base::Thread ipc("ipc"); |
337 ipc.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); | 331 ipc.StartWithOptions(base::Thread::Options(MessageLoop::TYPE_IO, 0)); |
338 | 332 |
339 StrictMock<MockChromeProxyDelegate> d1; | 333 StrictMock<MockChromeProxyDelegate> d1; |
340 TabsMap tab2delegate; | 334 TabsMap tab2delegate; |
341 SyncMsgSender queue(&tab2delegate); | 335 SyncMsgSender queue(&tab2delegate); |
342 | 336 |
343 const int kTabHandle = 6; | 337 const int kTabHandle = 6; |
344 const int kSessionId = 8; | 338 const int kSessionId = 8; |
345 | 339 |
346 // Create some sync messages and their replies. | 340 // Create a sync message and its reply. |
347 AutomationMsg_InstallExtension m1(FilePath(L"c:\\awesome.x"), 0); | 341 AutomationMsg_CreateExternalTab m(ExternalTabSettings(), 0, 0, 0, 0); |
348 AutomationMsg_CreateExternalTab m2(ExternalTabSettings(), 0, 0, 0, 0); | 342 scoped_ptr<IPC::Message> r(CreateReply(&m, (HWND)1, (HWND)2, kTabHandle, |
349 scoped_ptr<IPC::Message> r1(CreateReply(&m1, | 343 kSessionId)); |
350 AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED)); | |
351 scoped_ptr<IPC::Message> r2(CreateReply(&m2, (HWND)1, (HWND)2, kTabHandle, | |
352 kSessionId)); | |
353 | 344 |
354 queue.QueueSyncMessage(&m1, &d1, NULL); | 345 queue.QueueSyncMessage(&m, &d1, NULL); |
355 queue.QueueSyncMessage(&m2, &d1, NULL); | |
356 | 346 |
357 testing::InSequence s; | 347 testing::InSequence s; |
358 EXPECT_CALL(d1, Completed_InstallExtension(true, | |
359 AUTOMATION_MSG_EXTENSION_INSTALL_SUCCEEDED, NULL)); | |
360 EXPECT_CALL(d1, Completed_CreateTab(true, (HWND)1, (HWND)2, kTabHandle, | 348 EXPECT_CALL(d1, Completed_CreateTab(true, (HWND)1, (HWND)2, kTabHandle, |
361 kSessionId)); | 349 kSessionId)); |
362 | 350 |
363 // Execute replies in a worker thread. | 351 // Execute replies in a worker thread. |
364 ipc.message_loop()->PostTask(FROM_HERE, NewRunnableMethod(&queue, | 352 ipc.message_loop()->PostTask(FROM_HERE, NewRunnableMethod(&queue, |
365 &SyncMsgSender::OnReplyReceived, r1.get())); | 353 &SyncMsgSender::OnReplyReceived, r.get())); |
366 ipc.message_loop()->PostTask(FROM_HERE, NewRunnableMethod(&queue, | |
367 &SyncMsgSender::OnReplyReceived, r2.get())); | |
368 ipc.Stop(); | 354 ipc.Stop(); |
369 | 355 |
370 // Expect that tab 6 has been associated with the delegate. | 356 // Expect that tab 6 has been associated with the delegate. |
371 EXPECT_EQ(&d1, tab2delegate[6]); | 357 EXPECT_EQ(&d1, tab2delegate[6]); |
372 } | 358 } |
373 | 359 |
374 TEST(SyncMsgSender, OnChannelClosed) { | 360 TEST(SyncMsgSender, OnChannelClosed) { |
375 // TODO(stoyan): implement. | 361 // TODO(stoyan): implement. |
376 } | 362 } |
OLD | NEW |