| 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 #include <tuple> | 
| 6 | 7 | 
| 7 #include "content/browser/child_process_security_policy_impl.h" | 8 #include "content/browser/child_process_security_policy_impl.h" | 
| 8 #include "content/browser/media/webrtc/webrtc_identity_store.h" | 9 #include "content/browser/media/webrtc/webrtc_identity_store.h" | 
| 9 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" | 10 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" | 
| 10 #include "content/common/media/webrtc_identity_messages.h" | 11 #include "content/common/media/webrtc_identity_messages.h" | 
| 11 #include "content/public/test/mock_resource_context.h" | 12 #include "content/public/test/mock_resource_context.h" | 
| 12 #include "content/public/test/test_browser_thread_bundle.h" | 13 #include "content/public/test/test_browser_thread_bundle.h" | 
| 13 #include "content/test/test_content_browser_client.h" | 14 #include "content/test/test_content_browser_client.h" | 
| 14 #include "ipc/ipc_message.h" | 15 #include "ipc/ipc_message.h" | 
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" | 
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 152 | 153 | 
| 153   void SendCancelRequestToHost() { | 154   void SendCancelRequestToHost() { | 
| 154     host_->OnMessageReceived(WebRTCIdentityMsg_CancelRequest()); | 155     host_->OnMessageReceived(WebRTCIdentityMsg_CancelRequest()); | 
| 155   } | 156   } | 
| 156 | 157 | 
| 157   void VerifyRequestFailedMessage(int error) { | 158   void VerifyRequestFailedMessage(int error) { | 
| 158     EXPECT_EQ(1, host_->GetNumberOfMessages()); | 159     EXPECT_EQ(1, host_->GetNumberOfMessages()); | 
| 159     IPC::Message ipc = host_->GetLastMessage(); | 160     IPC::Message ipc = host_->GetLastMessage(); | 
| 160     EXPECT_EQ(ipc.type(), WebRTCIdentityHostMsg_RequestFailed::ID); | 161     EXPECT_EQ(ipc.type(), WebRTCIdentityHostMsg_RequestFailed::ID); | 
| 161 | 162 | 
| 162     base::Tuple<int, int> error_in_message; | 163     std::tuple<int, int> error_in_message; | 
| 163     WebRTCIdentityHostMsg_RequestFailed::Read(&ipc, &error_in_message); | 164     WebRTCIdentityHostMsg_RequestFailed::Read(&ipc, &error_in_message); | 
| 164     EXPECT_EQ(kFakeRequestId, base::get<0>(error_in_message)); | 165     EXPECT_EQ(kFakeRequestId, std::get<0>(error_in_message)); | 
| 165     EXPECT_EQ(error, base::get<1>(error_in_message)); | 166     EXPECT_EQ(error, std::get<1>(error_in_message)); | 
| 166   } | 167   } | 
| 167 | 168 | 
| 168   void VerifyIdentityReadyMessage(const std::string& cert, | 169   void VerifyIdentityReadyMessage(const std::string& cert, | 
| 169                                   const std::string& key) { | 170                                   const std::string& key) { | 
| 170     EXPECT_EQ(1, host_->GetNumberOfMessages()); | 171     EXPECT_EQ(1, host_->GetNumberOfMessages()); | 
| 171     IPC::Message ipc = host_->GetLastMessage(); | 172     IPC::Message ipc = host_->GetLastMessage(); | 
| 172     EXPECT_EQ(ipc.type(), WebRTCIdentityHostMsg_IdentityReady::ID); | 173     EXPECT_EQ(ipc.type(), WebRTCIdentityHostMsg_IdentityReady::ID); | 
| 173 | 174 | 
| 174     base::Tuple<int, std::string, std::string> identity_in_message; | 175     std::tuple<int, std::string, std::string> identity_in_message; | 
| 175     WebRTCIdentityHostMsg_IdentityReady::Read(&ipc, &identity_in_message); | 176     WebRTCIdentityHostMsg_IdentityReady::Read(&ipc, &identity_in_message); | 
| 176     EXPECT_EQ(kFakeRequestId, base::get<0>(identity_in_message)); | 177     EXPECT_EQ(kFakeRequestId, std::get<0>(identity_in_message)); | 
| 177     EXPECT_EQ(cert, base::get<1>(identity_in_message)); | 178     EXPECT_EQ(cert, std::get<1>(identity_in_message)); | 
| 178     EXPECT_EQ(key, base::get<2>(identity_in_message)); | 179     EXPECT_EQ(key, std::get<2>(identity_in_message)); | 
| 179   } | 180   } | 
| 180 | 181 | 
| 181  protected: | 182  protected: | 
| 182   TestBrowserThreadBundle browser_thread_bundle_; | 183   TestBrowserThreadBundle browser_thread_bundle_; | 
| 183   std::unique_ptr<MockResourceContext> mock_resource_context_; | 184   std::unique_ptr<MockResourceContext> mock_resource_context_; | 
| 184   scoped_refptr<MockWebRTCIdentityStore> store_; | 185   scoped_refptr<MockWebRTCIdentityStore> store_; | 
| 185   scoped_refptr<WebRTCIdentityServiceHostForTest> host_; | 186   scoped_refptr<WebRTCIdentityServiceHostForTest> host_; | 
| 186 }; | 187 }; | 
| 187 | 188 | 
| 188 }  // namespace | 189 }  // namespace | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 250 } | 251 } | 
| 251 | 252 | 
| 252 // Verifies that we do not crash if we try to cancel a completed request. | 253 // Verifies that we do not crash if we try to cancel a completed request. | 
| 253 TEST_F(WebRTCIdentityServiceHostTest, TestCancelAfterRequestCompleted) { | 254 TEST_F(WebRTCIdentityServiceHostTest, TestCancelAfterRequestCompleted) { | 
| 254   SendRequestToHost(); | 255   SendRequestToHost(); | 
| 255   store_->RunCompletionCallback(net::OK, kFakeCertificate, kFakePrivateKey); | 256   store_->RunCompletionCallback(net::OK, kFakeCertificate, kFakePrivateKey); | 
| 256   SendCancelRequestToHost(); | 257   SendCancelRequestToHost(); | 
| 257 } | 258 } | 
| 258 | 259 | 
| 259 }  // namespace content | 260 }  // namespace content | 
| OLD | NEW | 
|---|