| 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/client.h" | 5 #include "components/proximity_auth/client.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "components/proximity_auth/client_observer.h" | 9 #include "components/proximity_auth/client_observer.h" |
| 10 #include "components/proximity_auth/connection.h" | 10 #include "components/proximity_auth/connection.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 const char kFakeEncodingSuffix[] = ", but encoded"; | 32 const char kFakeEncodingSuffix[] = ", but encoded"; |
| 33 | 33 |
| 34 class MockSecureContext : public SecureContext { | 34 class MockSecureContext : public SecureContext { |
| 35 public: | 35 public: |
| 36 MockSecureContext() { | 36 MockSecureContext() { |
| 37 // By default, mock a secure context that uses the 3.1 protocol. Individual | 37 // By default, mock a secure context that uses the 3.1 protocol. Individual |
| 38 // tests override this as needed. | 38 // tests override this as needed. |
| 39 ON_CALL(*this, GetProtocolVersion()) | 39 ON_CALL(*this, GetProtocolVersion()) |
| 40 .WillByDefault(Return(SecureContext::PROTOCOL_VERSION_THREE_ONE)); | 40 .WillByDefault(Return(SecureContext::PROTOCOL_VERSION_THREE_ONE)); |
| 41 } | 41 } |
| 42 virtual ~MockSecureContext() {} | 42 ~MockSecureContext() override {} |
| 43 | 43 |
| 44 MOCK_CONST_METHOD0(GetReceivedAuthMessage, std::string()); | 44 MOCK_CONST_METHOD0(GetReceivedAuthMessage, std::string()); |
| 45 MOCK_CONST_METHOD0(GetProtocolVersion, ProtocolVersion()); | 45 MOCK_CONST_METHOD0(GetProtocolVersion, ProtocolVersion()); |
| 46 | 46 |
| 47 virtual std::string Encode(const std::string& message) override { | 47 std::string Encode(const std::string& message) override { |
| 48 return message + kFakeEncodingSuffix; | 48 return message + kFakeEncodingSuffix; |
| 49 } | 49 } |
| 50 | 50 |
| 51 virtual std::string Decode(const std::string& encoded_message) override { | 51 std::string Decode(const std::string& encoded_message) override { |
| 52 EXPECT_THAT(encoded_message, EndsWith(kFakeEncodingSuffix)); | 52 EXPECT_THAT(encoded_message, EndsWith(kFakeEncodingSuffix)); |
| 53 std::string decoded_message = encoded_message; | 53 std::string decoded_message = encoded_message; |
| 54 decoded_message.erase(decoded_message.rfind(kFakeEncodingSuffix)); | 54 decoded_message.erase(decoded_message.rfind(kFakeEncodingSuffix)); |
| 55 return decoded_message; | 55 return decoded_message; |
| 56 } | 56 } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(MockSecureContext); | 59 DISALLOW_COPY_AND_ASSIGN(MockSecureContext); |
| 60 }; | 60 }; |
| 61 | 61 |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 "\"data\":\"YSB3aW5uZXIgaXMgeW91\"" | 504 "\"data\":\"YSB3aW5uZXIgaXMgeW91\"" |
| 505 "}, but encoded"); | 505 "}, but encoded"); |
| 506 | 506 |
| 507 // The unlock request should have remained buffered, and should only now be | 507 // The unlock request should have remained buffered, and should only now be |
| 508 // sent. | 508 // sent. |
| 509 EXPECT_CALL(observer, OnUnlockResponse(false)); | 509 EXPECT_CALL(observer, OnUnlockResponse(false)); |
| 510 client.GetFakeConnection()->FinishSendingMessageWithSuccess(false); | 510 client.GetFakeConnection()->FinishSendingMessageWithSuccess(false); |
| 511 } | 511 } |
| 512 | 512 |
| 513 } // namespace proximity_auth | 513 } // namespace proximity_auth |
| OLD | NEW |