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

Side by Side Diff: components/proximity_auth/connection_unittest.cc

Issue 663693002: [Easy Unlock] Port the BluetoothThrottler class to native code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compilation error, take 2 Created 5 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/proximity_auth/connection.h" 5 #include "components/proximity_auth/connection.h"
6 6
7 #include "components/proximity_auth/connection_observer.h" 7 #include "components/proximity_auth/connection_observer.h"
8 #include "components/proximity_auth/remote_device.h" 8 #include "components/proximity_auth/remote_device.h"
9 #include "components/proximity_auth/wire_message.h" 9 #include "components/proximity_auth/wire_message.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 private: 52 private:
53 DISALLOW_COPY_AND_ASSIGN(MockConnection); 53 DISALLOW_COPY_AND_ASSIGN(MockConnection);
54 }; 54 };
55 55
56 class MockConnectionObserver : public ConnectionObserver { 56 class MockConnectionObserver : public ConnectionObserver {
57 public: 57 public:
58 MockConnectionObserver() {} 58 MockConnectionObserver() {}
59 virtual ~MockConnectionObserver() {} 59 virtual ~MockConnectionObserver() {}
60 60
61 MOCK_METHOD3(OnConnectionStatusChanged, 61 MOCK_METHOD3(OnConnectionStatusChanged,
62 void(const Connection& connection, 62 void(Connection* connection,
63 Connection::Status old_status, 63 Connection::Status old_status,
64 Connection::Status new_status)); 64 Connection::Status new_status));
65 MOCK_METHOD2(OnMessageReceived, 65 MOCK_METHOD2(OnMessageReceived,
66 void(const Connection& connection, const WireMessage& message)); 66 void(const Connection& connection, const WireMessage& message));
67 MOCK_METHOD3(OnSendCompleted, 67 MOCK_METHOD3(OnSendCompleted,
68 void(const Connection& connection, 68 void(const Connection& connection,
69 const WireMessage& message, 69 const WireMessage& message,
70 bool success)); 70 bool success));
71 71
72 private: 72 private:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 connection.SendMessage(scoped_ptr<WireMessage>()); 136 connection.SendMessage(scoped_ptr<WireMessage>());
137 } 137 }
138 138
139 TEST(ProximityAuthConnectionTest, SetStatus_NotifiesObserversOfStatusChange) { 139 TEST(ProximityAuthConnectionTest, SetStatus_NotifiesObserversOfStatusChange) {
140 StrictMock<MockConnection> connection; 140 StrictMock<MockConnection> connection;
141 EXPECT_EQ(Connection::DISCONNECTED, connection.status()); 141 EXPECT_EQ(Connection::DISCONNECTED, connection.status());
142 142
143 StrictMock<MockConnectionObserver> observer; 143 StrictMock<MockConnectionObserver> observer;
144 connection.AddObserver(&observer); 144 connection.AddObserver(&observer);
145 145
146 EXPECT_CALL( 146 EXPECT_CALL(observer,
147 observer, 147 OnConnectionStatusChanged(&connection, Connection::DISCONNECTED,
148 OnConnectionStatusChanged( 148 Connection::CONNECTED));
149 Ref(connection), Connection::DISCONNECTED, Connection::CONNECTED));
150 connection.SetStatus(Connection::CONNECTED); 149 connection.SetStatus(Connection::CONNECTED);
151 } 150 }
152 151
153 TEST(ProximityAuthConnectionTest, 152 TEST(ProximityAuthConnectionTest,
154 SetStatus_DoesntNotifyObserversIfStatusUnchanged) { 153 SetStatus_DoesntNotifyObserversIfStatusUnchanged) {
155 StrictMock<MockConnection> connection; 154 StrictMock<MockConnection> connection;
156 EXPECT_EQ(Connection::DISCONNECTED, connection.status()); 155 EXPECT_EQ(Connection::DISCONNECTED, connection.status());
157 156
158 StrictMock<MockConnectionObserver> observer; 157 StrictMock<MockConnectionObserver> observer;
159 connection.AddObserver(&observer); 158 connection.AddObserver(&observer);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 connection.AddObserver(&observer); 237 connection.AddObserver(&observer);
239 238
240 ON_CALL(connection, DeserializeWireMessageProxy(_)) 239 ON_CALL(connection, DeserializeWireMessageProxy(_))
241 .WillByDefault(DoAll(SetArgPointee<0>(false), 240 .WillByDefault(DoAll(SetArgPointee<0>(false),
242 Return(static_cast<WireMessage*>(NULL)))); 241 Return(static_cast<WireMessage*>(NULL))));
243 EXPECT_CALL(observer, OnMessageReceived(_, _)).Times(0); 242 EXPECT_CALL(observer, OnMessageReceived(_, _)).Times(0);
244 connection.OnBytesReceived(std::string()); 243 connection.OnBytesReceived(std::string());
245 } 244 }
246 245
247 } // namespace proximity_auth 246 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/proximity_auth/connection_observer.h ('k') | components/proximity_auth/throttled_bluetooth_connection_finder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698