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

Side by Side Diff: ceee/ie/broker/broker_rpc_unittest.cc

Issue 4989002: Firing event to broker without worker thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 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 | « ceee/ie/broker/broker_rpc_server.cc ('k') | ceee/ie/broker/chrome_postman.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "ceee/ie/broker/broker_rpc_client.h" 5 #include "ceee/ie/broker/broker_rpc_client.h"
6 #include "ceee/ie/broker/broker_rpc_server.h" 6 #include "ceee/ie/broker/broker_rpc_server.h"
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include "broker_rpc_lib.h" // NOLINT 9 #include "broker_rpc_lib.h" // NOLINT
10 #include "ceee/ie/broker/broker_rpc_utils.h" 10 #include "ceee/ie/broker/broker_rpc_utils.h"
(...skipping 10 matching lines...) Expand all
21 namespace { 21 namespace {
22 22
23 using testing::_; 23 using testing::_;
24 24
25 MOCK_STATIC_CLASS_BEGIN(BrokerRpcMock) 25 MOCK_STATIC_CLASS_BEGIN(BrokerRpcMock)
26 MOCK_STATIC_INIT_BEGIN(BrokerRpcMock) 26 MOCK_STATIC_INIT_BEGIN(BrokerRpcMock)
27 MOCK_STATIC_INIT(GetRpcEndPointAddress); 27 MOCK_STATIC_INIT(GetRpcEndPointAddress);
28 MOCK_STATIC_INIT(BrokerRpcServer_FireEvent) 28 MOCK_STATIC_INIT(BrokerRpcServer_FireEvent)
29 MOCK_STATIC_INIT_END() 29 MOCK_STATIC_INIT_END()
30 MOCK_STATIC0(std::wstring, , GetRpcEndPointAddress); 30 MOCK_STATIC0(std::wstring, , GetRpcEndPointAddress);
31 MOCK_STATIC3(void, , BrokerRpcServer_FireEvent, handle_t, BSTR, BSTR); 31 MOCK_STATIC3(void, , BrokerRpcServer_FireEvent, handle_t, const char*,
32 const char*);
32 MOCK_STATIC_CLASS_END(BrokerRpcMock) 33 MOCK_STATIC_CLASS_END(BrokerRpcMock)
33 34
34 class BrokerRpcTest : public testing::Test { 35 class BrokerRpcTest : public testing::Test {
35 protected: 36 protected:
36 virtual void SetUp() { 37 virtual void SetUp() {
37 EXPECT_CALL(broker_rpc_mock_, GetRpcEndPointAddress()) 38 EXPECT_CALL(broker_rpc_mock_, GetRpcEndPointAddress())
38 .WillRepeatedly(Return(L"BrokerRpcTestEP")); 39 .WillRepeatedly(Return(L"BrokerRpcTestEP"));
39 } 40 }
40 41
41 virtual void TearDown() { 42 virtual void TearDown() {
42 } 43 }
43 44
44 BrokerRpcMock broker_rpc_mock_; 45 BrokerRpcMock broker_rpc_mock_;
45 }; 46 };
46 47
47 TEST_F(BrokerRpcTest, ConnectNoServer) { 48 TEST_F(BrokerRpcTest, ConnectNoServer) {
48 BrokerRpcClient client; 49 BrokerRpcClient client;
49 ASSERT_FALSE(client.is_connected()); 50 ASSERT_FALSE(client.is_connected());
50 ASSERT_FALSE(client.Connect()); 51 ASSERT_FALSE(SUCCEEDED(client.Connect()));
51 ASSERT_FALSE(client.is_connected()); 52 ASSERT_FALSE(client.is_connected());
52 } 53 }
53 54
54 TEST_F(BrokerRpcTest, Connect) { 55 TEST_F(BrokerRpcTest, Connect) {
55 BrokerRpcServer server; 56 BrokerRpcServer server;
56 ASSERT_FALSE(server.is_started()); 57 ASSERT_FALSE(server.is_started());
57 ASSERT_TRUE(server.Start()); 58 ASSERT_TRUE(server.Start());
58 ASSERT_TRUE(server.is_started()); 59 ASSERT_TRUE(server.is_started());
59 BrokerRpcClient client; 60 BrokerRpcClient client;
60 ASSERT_TRUE(client.Connect()); 61 ASSERT_TRUE(SUCCEEDED(client.Connect()));
61 ASSERT_TRUE(client.is_connected()); 62 ASSERT_TRUE(client.is_connected());
62 } 63 }
63 64
64 TEST_F(BrokerRpcTest, FireEvent) { 65 TEST_F(BrokerRpcTest, FireEvent) {
65 BrokerRpcServer server; 66 BrokerRpcServer server;
66 ASSERT_TRUE(server.Start()); 67 ASSERT_TRUE(server.Start());
67 68
68 BrokerRpcClient client; 69 BrokerRpcClient client;
69 ASSERT_TRUE(client.Connect()); 70 ASSERT_TRUE(SUCCEEDED(client.Connect()));
70 71
71 CComBSTR event_name = L"event_name"; 72 const char* event_name = "event_name";
72 CComBSTR event_args = L"event_args"; 73 const char* event_args = "event_args";
73 74
74 EXPECT_CALL(broker_rpc_mock_, BrokerRpcServer_FireEvent(_, 75 EXPECT_CALL(broker_rpc_mock_, BrokerRpcServer_FireEvent(_, StrEq(event_name),
75 StrEq(event_name.m_str), StrEq(event_args.m_str))) 76 StrEq(event_args)))
76 .Times(1); 77 .Times(1);
77 78
78 ASSERT_TRUE(client.FireEvent(event_name, event_args)); 79 ASSERT_TRUE(SUCCEEDED(client.FireEvent(event_name, event_args)));
79 } 80 }
80 81
81 } // namespace 82 } // namespace
OLDNEW
« no previous file with comments | « ceee/ie/broker/broker_rpc_server.cc ('k') | ceee/ie/broker/chrome_postman.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698