| Index: android_webview/native/aw_contents_client_bridge_unittest.cc
|
| diff --git a/android_webview/native/aw_contents_client_bridge_unittest.cc b/android_webview/native/aw_contents_client_bridge_unittest.cc
|
| index b301f9199276f1923f676564ef3054181b0ed6f8..d71decc1e9b4e3bea00aa9017d86da0f1006f6ca 100644
|
| --- a/android_webview/native/aw_contents_client_bridge_unittest.cc
|
| +++ b/android_webview/native/aw_contents_client_bridge_unittest.cc
|
| @@ -8,8 +8,10 @@
|
| #include "base/android/jni_array.h"
|
| #include "base/android/scoped_java_ref.h"
|
| #include "base/bind.h"
|
| +#include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/run_loop.h"
|
| +#include "content/public/browser/client_certificate_delegate.h"
|
| #include "content/public/test/test_browser_thread_bundle.h"
|
| #include "jni/MockAwContentsClientBridge_jni.h"
|
| #include "net/android/net_jni_registrar.h"
|
| @@ -33,9 +35,6 @@ namespace {
|
| // Tests the android_webview contents client bridge.
|
| class AwContentsClientBridgeTest : public Test {
|
| public:
|
| - typedef AwContentsClientBridge::SelectCertificateCallback
|
| - SelectCertificateCallback;
|
| -
|
| AwContentsClientBridgeTest() { }
|
|
|
| // Callback method called when a cert is selected.
|
| @@ -53,6 +52,26 @@ class AwContentsClientBridgeTest : public Test {
|
| JNIEnv* env_;
|
| };
|
|
|
| +class TestClientCertificateDelegate
|
| + : public content::ClientCertificateDelegate {
|
| + public:
|
| + explicit TestClientCertificateDelegate(AwContentsClientBridgeTest* test)
|
| + : test_(test) {}
|
| +
|
| + ~TestClientCertificateDelegate() override { EXPECT_FALSE(test_); }
|
| +
|
| + // content::ClientCertificateDelegate.
|
| + void ContinueWithCertificate(net::X509Certificate* cert) override {
|
| + test_->CertSelected(cert);
|
| + test_ = nullptr;
|
| + }
|
| +
|
| + private:
|
| + AwContentsClientBridgeTest* test_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TestClientCertificateDelegate);
|
| +};
|
| +
|
| } // namespace
|
|
|
| void AwContentsClientBridgeTest::SetUp() {
|
| @@ -90,9 +109,7 @@ void AwContentsClientBridgeTest::TestCertType(SSLClientCertType type,
|
| cert_request_info_->cert_key_types.push_back(type);
|
| bridge_->SelectClientCertificate(
|
| cert_request_info_.get(),
|
| - base::Bind(
|
| - &AwContentsClientBridgeTest::CertSelected,
|
| - base::Unretained(static_cast<AwContentsClientBridgeTest*>(this))));
|
| + make_scoped_ptr(new TestClientCertificateDelegate(this)));
|
| base::RunLoop().RunUntilIdle();
|
| EXPECT_EQ(0, cert_selected_callbacks_);
|
| ScopedJavaLocalRef<jobjectArray> key_types =
|
| @@ -112,10 +129,8 @@ TEST_F(AwContentsClientBridgeTest,
|
| // Call SelectClientCertificate to create a callback id that mock java object
|
| // can call on.
|
| bridge_->SelectClientCertificate(
|
| - cert_request_info_.get(),
|
| - base::Bind(
|
| - &AwContentsClientBridgeTest::CertSelected,
|
| - base::Unretained(static_cast<AwContentsClientBridgeTest*>(this))));
|
| + cert_request_info_.get(),
|
| + make_scoped_ptr(new TestClientCertificateDelegate(this)));
|
| bridge_->ProvideClientCertificateResponse(env_, jbridge_.obj(),
|
| Java_MockAwContentsClientBridge_getRequestId(env_, jbridge_.obj()),
|
| Java_MockAwContentsClientBridge_createTestCertChain(
|
| @@ -133,10 +148,8 @@ TEST_F(AwContentsClientBridgeTest,
|
| // Call SelectClientCertificate to create a callback id that mock java object
|
| // can call on.
|
| bridge_->SelectClientCertificate(
|
| - cert_request_info_.get(),
|
| - base::Bind(
|
| - &AwContentsClientBridgeTest::CertSelected,
|
| - base::Unretained(static_cast<AwContentsClientBridgeTest*>(this))));
|
| + cert_request_info_.get(),
|
| + make_scoped_ptr(new TestClientCertificateDelegate(this)));
|
| int requestId =
|
| Java_MockAwContentsClientBridge_getRequestId(env_, jbridge_.obj());
|
| bridge_->ProvideClientCertificateResponse(env_, jbridge_.obj(),
|
|
|