OLD | NEW |
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/messenger_impl.h" | 5 #include "components/proximity_auth/messenger_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "components/proximity_auth/connection.h" | 10 #include "components/proximity_auth/connection.h" |
11 #include "components/proximity_auth/fake_connection.h" | 11 #include "components/proximity_auth/fake_connection.h" |
12 #include "components/proximity_auth/messenger_observer.h" | 12 #include "components/proximity_auth/messenger_observer.h" |
| 13 #include "components/proximity_auth/proximity_auth_test_util.h" |
13 #include "components/proximity_auth/remote_device.h" | 14 #include "components/proximity_auth/remote_device.h" |
14 #include "components/proximity_auth/remote_status_update.h" | 15 #include "components/proximity_auth/remote_status_update.h" |
15 #include "components/proximity_auth/secure_context.h" | 16 #include "components/proximity_auth/secure_context.h" |
16 #include "components/proximity_auth/wire_message.h" | 17 #include "components/proximity_auth/wire_message.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 | 20 |
20 using testing::_; | 21 using testing::_; |
21 using testing::AllOf; | 22 using testing::AllOf; |
22 using testing::EndsWith; | 23 using testing::EndsWith; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 private: | 86 private: |
86 // The messenger that |this| instance observes. | 87 // The messenger that |this| instance observes. |
87 Messenger* const messenger_; | 88 Messenger* const messenger_; |
88 | 89 |
89 DISALLOW_COPY_AND_ASSIGN(MockMessengerObserver); | 90 DISALLOW_COPY_AND_ASSIGN(MockMessengerObserver); |
90 }; | 91 }; |
91 | 92 |
92 class TestMessenger : public MessengerImpl { | 93 class TestMessenger : public MessengerImpl { |
93 public: | 94 public: |
94 TestMessenger() | 95 TestMessenger() |
95 : MessengerImpl(make_scoped_ptr(new FakeConnection(RemoteDevice())), | 96 : MessengerImpl(make_scoped_ptr(new FakeConnection( |
| 97 CreateClassicRemoteDeviceForTest())), |
96 make_scoped_ptr(new NiceMock<MockSecureContext>())) {} | 98 make_scoped_ptr(new NiceMock<MockSecureContext>())) {} |
97 ~TestMessenger() override {} | 99 ~TestMessenger() override {} |
98 | 100 |
99 // Simple getters for the mock objects owned by |this| messenger. | 101 // Simple getters for the mock objects owned by |this| messenger. |
100 FakeConnection* GetFakeConnection() { | 102 FakeConnection* GetFakeConnection() { |
101 return static_cast<FakeConnection*>(connection()); | 103 return static_cast<FakeConnection*>(connection()); |
102 } | 104 } |
103 MockSecureContext* GetMockSecureContext() { | 105 MockSecureContext* GetMockSecureContext() { |
104 return static_cast<MockSecureContext*>(secure_context()); | 106 return static_cast<MockSecureContext*>(secure_context()); |
105 } | 107 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 "\"data\":\"YSB3aW5uZXIgaXMgeW91\"" | 462 "\"data\":\"YSB3aW5uZXIgaXMgeW91\"" |
461 "}, but encoded"); | 463 "}, but encoded"); |
462 | 464 |
463 // The unlock request should have remained buffered, and should only now be | 465 // The unlock request should have remained buffered, and should only now be |
464 // sent. | 466 // sent. |
465 EXPECT_CALL(observer, OnUnlockResponse(false)); | 467 EXPECT_CALL(observer, OnUnlockResponse(false)); |
466 messenger.GetFakeConnection()->FinishSendingMessageWithSuccess(false); | 468 messenger.GetFakeConnection()->FinishSendingMessageWithSuccess(false); |
467 } | 469 } |
468 | 470 |
469 } // namespace proximity_auth | 471 } // namespace proximity_auth |
OLD | NEW |