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 "android_webview/native/aw_contents_client_bridge.h" | 5 #include "android_webview/native/aw_contents_client_bridge.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
9 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "content/public/browser/client_certificate_delegate.h" | 14 #include "content/public/browser/client_certificate_delegate.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "jni/MockAwContentsClientBridge_jni.h" | 16 #include "jni/MockAwContentsClientBridge_jni.h" |
17 #include "net/android/net_jni_registrar.h" | 17 #include "net/android/net_jni_registrar.h" |
18 #include "net/ssl/ssl_cert_request_info.h" | 18 #include "net/ssl/ssl_cert_request_info.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
22 | 22 |
23 using base::android::AttachCurrentThread; | 23 using base::android::AttachCurrentThread; |
24 using base::android::ScopedJavaLocalRef; | 24 using base::android::ScopedJavaLocalRef; |
25 using net::SSLCertRequestInfo; | 25 using net::SSLCertRequestInfo; |
26 using net::SSLClientCertType; | 26 using net::SSLClientCertType; |
| 27 using net::SSLPrivateKey; |
27 using net::X509Certificate; | 28 using net::X509Certificate; |
28 using testing::NotNull; | 29 using testing::NotNull; |
29 using testing::Test; | 30 using testing::Test; |
30 | 31 |
31 namespace android_webview { | 32 namespace android_webview { |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 // Tests the android_webview contents client bridge. | 36 // Tests the android_webview contents client bridge. |
36 class AwContentsClientBridgeTest : public Test { | 37 class AwContentsClientBridgeTest : public Test { |
(...skipping 15 matching lines...) Expand all Loading... |
52 JNIEnv* env_; | 53 JNIEnv* env_; |
53 }; | 54 }; |
54 | 55 |
55 class TestClientCertificateDelegate | 56 class TestClientCertificateDelegate |
56 : public content::ClientCertificateDelegate { | 57 : public content::ClientCertificateDelegate { |
57 public: | 58 public: |
58 explicit TestClientCertificateDelegate(AwContentsClientBridgeTest* test) | 59 explicit TestClientCertificateDelegate(AwContentsClientBridgeTest* test) |
59 : test_(test) {} | 60 : test_(test) {} |
60 | 61 |
61 // content::ClientCertificateDelegate. | 62 // content::ClientCertificateDelegate. |
62 void ContinueWithCertificate(net::X509Certificate* cert) override { | 63 void ContinueWithCertificate(net::X509Certificate* cert, |
| 64 net::SSLPrivateKey* private_key) override { |
63 test_->CertSelected(cert); | 65 test_->CertSelected(cert); |
64 test_ = nullptr; | 66 test_ = nullptr; |
65 } | 67 } |
66 | 68 |
67 private: | 69 private: |
68 AwContentsClientBridgeTest* test_; | 70 AwContentsClientBridgeTest* test_; |
69 | 71 |
70 DISALLOW_COPY_AND_ASSIGN(TestClientCertificateDelegate); | 72 DISALLOW_COPY_AND_ASSIGN(TestClientCertificateDelegate); |
71 }; | 73 }; |
72 | 74 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 requestId, | 156 requestId, |
155 NULL, | 157 NULL, |
156 Java_MockAwContentsClientBridge_createTestPrivateKey( | 158 Java_MockAwContentsClientBridge_createTestPrivateKey( |
157 env_, jbridge_.obj()).obj()); | 159 env_, jbridge_.obj()).obj()); |
158 base::RunLoop().RunUntilIdle(); | 160 base::RunLoop().RunUntilIdle(); |
159 EXPECT_EQ(NULL, selected_cert_); | 161 EXPECT_EQ(NULL, selected_cert_); |
160 EXPECT_EQ(1, cert_selected_callbacks_); | 162 EXPECT_EQ(1, cert_selected_callbacks_); |
161 } | 163 } |
162 | 164 |
163 } // android_webview | 165 } // android_webview |
OLD | NEW |