Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: android_webview/native/aw_contents_client_bridge_unittest.cc

Issue 1474603004: Remove Android support for out-of-process KeyStores (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 void AwContentsClientBridgeTest::SetUp() { 75 void AwContentsClientBridgeTest::SetUp() {
76 env_ = AttachCurrentThread(); 76 env_ = AttachCurrentThread();
77 ASSERT_THAT(env_, NotNull()); 77 ASSERT_THAT(env_, NotNull());
78 ASSERT_TRUE(android_webview::RegisterAwContentsClientBridge(env_)); 78 ASSERT_TRUE(android_webview::RegisterAwContentsClientBridge(env_));
79 ASSERT_TRUE(RegisterNativesImpl(env_)); 79 ASSERT_TRUE(RegisterNativesImpl(env_));
80 ASSERT_TRUE(net::android::RegisterJni(env_)); 80 ASSERT_TRUE(net::android::RegisterJni(env_));
81 jbridge_.Reset(env_, 81 jbridge_.Reset(env_,
82 Java_MockAwContentsClientBridge_getAwContentsClientBridge(env_).obj()); 82 Java_MockAwContentsClientBridge_getAwContentsClientBridge(env_).obj());
83 bridge_.reset(new AwContentsClientBridge(env_, jbridge_.obj())); 83 bridge_.reset(new AwContentsClientBridge(env_, jbridge_.obj()));
84 selected_cert_ = NULL; 84 selected_cert_ = nullptr;
85 cert_selected_callbacks_ = 0; 85 cert_selected_callbacks_ = 0;
86 cert_request_info_ = new net::SSLCertRequestInfo; 86 cert_request_info_ = new net::SSLCertRequestInfo;
87 } 87 }
88 88
89 void AwContentsClientBridgeTest::CertSelected(X509Certificate* cert) { 89 void AwContentsClientBridgeTest::CertSelected(X509Certificate* cert) {
90 selected_cert_ = cert; 90 selected_cert_ = cert;
91 cert_selected_callbacks_++; 91 cert_selected_callbacks_++;
92 } 92 }
93 93
94 TEST_F(AwContentsClientBridgeTest, TestClientCertKeyTypesCorrectlyEncoded) { 94 TEST_F(AwContentsClientBridgeTest, TestClientCertKeyTypesCorrectlyEncoded) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 TestProvideClientCertificateResponseCallsCallbackOnNullKey) { 126 TestProvideClientCertificateResponseCallsCallbackOnNullKey) {
127 // Call SelectClientCertificate to create a callback id that mock java object 127 // Call SelectClientCertificate to create a callback id that mock java object
128 // can call on. 128 // can call on.
129 bridge_->SelectClientCertificate( 129 bridge_->SelectClientCertificate(
130 cert_request_info_.get(), 130 cert_request_info_.get(),
131 make_scoped_ptr(new TestClientCertificateDelegate(this))); 131 make_scoped_ptr(new TestClientCertificateDelegate(this)));
132 bridge_->ProvideClientCertificateResponse(env_, jbridge_.obj(), 132 bridge_->ProvideClientCertificateResponse(env_, jbridge_.obj(),
133 Java_MockAwContentsClientBridge_getRequestId(env_, jbridge_.obj()), 133 Java_MockAwContentsClientBridge_getRequestId(env_, jbridge_.obj()),
134 Java_MockAwContentsClientBridge_createTestCertChain( 134 Java_MockAwContentsClientBridge_createTestCertChain(
135 env_, jbridge_.obj()).obj(), 135 env_, jbridge_.obj()).obj(),
136 NULL); 136 nullptr);
137 base::RunLoop().RunUntilIdle(); 137 base::RunLoop().RunUntilIdle();
138 EXPECT_EQ(NULL, selected_cert_); 138 EXPECT_EQ(nullptr, selected_cert_);
139 EXPECT_EQ(1, cert_selected_callbacks_); 139 EXPECT_EQ(1, cert_selected_callbacks_);
140 } 140 }
141 141
142 // Verify that ProvideClientCertificateResponse calls the callback with 142 // Verify that ProvideClientCertificateResponse calls the callback with
143 // NULL parameters when private key is not provided. 143 // null parameters when private key is not provided.
144 TEST_F(AwContentsClientBridgeTest, 144 TEST_F(AwContentsClientBridgeTest,
145 TestProvideClientCertificateResponseCallsCallbackOnNullChain) { 145 TestProvideClientCertificateResponseCallsCallbackOnNullChain) {
146 // Call SelectClientCertificate to create a callback id that mock java object 146 // Call SelectClientCertificate to create a callback id that mock java object
147 // can call on. 147 // can call on.
148 bridge_->SelectClientCertificate( 148 bridge_->SelectClientCertificate(
149 cert_request_info_.get(), 149 cert_request_info_.get(),
150 make_scoped_ptr(new TestClientCertificateDelegate(this))); 150 make_scoped_ptr(new TestClientCertificateDelegate(this)));
151 int requestId = 151 int requestId =
152 Java_MockAwContentsClientBridge_getRequestId(env_, jbridge_.obj()); 152 Java_MockAwContentsClientBridge_getRequestId(env_, jbridge_.obj());
153 bridge_->ProvideClientCertificateResponse(env_, jbridge_.obj(), 153 bridge_->ProvideClientCertificateResponse(
154 requestId, 154 env_, jbridge_.obj(), requestId, nullptr, nullptr);
155 NULL,
156 Java_MockAwContentsClientBridge_createTestPrivateKey(
157 env_, jbridge_.obj()).obj());
158 base::RunLoop().RunUntilIdle(); 155 base::RunLoop().RunUntilIdle();
159 EXPECT_EQ(NULL, selected_cert_); 156 EXPECT_EQ(nullptr, selected_cert_);
160 EXPECT_EQ(1, cert_selected_callbacks_); 157 EXPECT_EQ(1, cert_selected_callbacks_);
161 } 158 }
162 159
163 } // android_webview 160 } // android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698