OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <deque> | 5 #include <deque> |
6 | 6 |
7 #include "content/common/media/webrtc_identity_messages.h" | 7 #include "content/common/media/webrtc_identity_messages.h" |
8 #include "content/renderer/media/webrtc_identity_service.h" | 8 #include "content/renderer/media/webrtc_identity_service.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 static const char FAKE_ORIGIN[] = "http://fake.com"; | 16 static const char FAKE_ORIGIN[] = "http://fake.com"; |
17 static const char FAKE_IDENTITY_NAME[] = "fake identity"; | 17 static const char FAKE_IDENTITY_NAME[] = "fake identity"; |
18 static const char FAKE_COMMON_NAME[] = "fake common name"; | 18 static const char FAKE_COMMON_NAME[] = "fake common name"; |
19 static const char FAKE_CERTIFICATE[] = "fake cert"; | 19 static const char FAKE_CERTIFICATE[] = "fake cert"; |
20 static const char FAKE_PRIVATE_KEY[] = "fake private key"; | 20 static const char FAKE_PRIVATE_KEY[] = "fake private key"; |
21 static const int FAKE_ERROR = 100; | 21 static const int FAKE_ERROR = 100; |
22 | 22 |
23 class WebRTCIdentityServiceForTest : public WebRTCIdentityService { | 23 class WebRTCIdentityServiceForTest : public WebRTCIdentityService { |
24 public: | 24 public: |
25 virtual bool Send(IPC::Message* message) override { | 25 bool Send(IPC::Message* message) override { |
26 messages_.push_back(*message); | 26 messages_.push_back(*message); |
27 delete message; | 27 delete message; |
28 return true; | 28 return true; |
29 } | 29 } |
30 | 30 |
31 virtual bool OnControlMessageReceived(const IPC::Message& message) override { | 31 bool OnControlMessageReceived(const IPC::Message& message) override { |
32 return WebRTCIdentityService::OnControlMessageReceived(message); | 32 return WebRTCIdentityService::OnControlMessageReceived(message); |
33 } | 33 } |
34 | 34 |
35 IPC::Message GetLastMessage() { return messages_.back(); } | 35 IPC::Message GetLastMessage() { return messages_.back(); } |
36 | 36 |
37 int GetNumberOfMessages() { return messages_.size(); } | 37 int GetNumberOfMessages() { return messages_.size(); } |
38 | 38 |
39 void ClearMessages() { messages_.clear(); } | 39 void ClearMessages() { messages_.clear(); } |
40 | 40 |
41 private: | 41 private: |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 219 |
220 EXPECT_NE(FAKE_CERTIFICATE, last_certificate_); | 220 EXPECT_NE(FAKE_CERTIFICATE, last_certificate_); |
221 EXPECT_NE(FAKE_PRIVATE_KEY, last_private_key_); | 221 EXPECT_NE(FAKE_PRIVATE_KEY, last_private_key_); |
222 | 222 |
223 service_->OnControlMessageReceived( | 223 service_->OnControlMessageReceived( |
224 WebRTCIdentityHostMsg_RequestFailed(id1, FAKE_ERROR)); | 224 WebRTCIdentityHostMsg_RequestFailed(id1, FAKE_ERROR)); |
225 EXPECT_NE(FAKE_ERROR, last_error_); | 225 EXPECT_NE(FAKE_ERROR, last_error_); |
226 } | 226 } |
227 | 227 |
228 } // namespace content | 228 } // namespace content |
OLD | NEW |