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

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/SSLClientCertificateRequestTest.java

Issue 1327103003: Handle ActivityNotFoundException when selecting client cert (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated string descriptions Created 5 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/strings/android_chrome_strings.grd ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/junit/src/org/chromium/chrome/browser/SSLClientCertificateRequestTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/SSLClientCertificateRequestTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/SSLClientCertificateRequestTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..ea66e3c5af2c746861acdd21e0117dc9da4aaa46
--- /dev/null
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/SSLClientCertificateRequestTest.java
@@ -0,0 +1,62 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser;
+
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
+import android.content.ActivityNotFoundException;
+import android.security.KeyChainAliasCallback;
+
+import org.chromium.chrome.browser.SSLClientCertificateRequest.CertSelectionFailureDialog;
+import org.chromium.chrome.browser.SSLClientCertificateRequest.KeyChainCertSelectionWrapper;
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import org.robolectric.annotation.Config;
+
+/**
+ * Unit tests for the SSLClientCertificateRequest class.
+ */
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class SSLClientCertificateRequestTest {
+ @Mock private KeyChainCertSelectionWrapper mKeyChainMock;
+ @Mock private KeyChainAliasCallback mCallbackMock;
+ @Mock private CertSelectionFailureDialog mFailureDialogMock;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testSelectCertActivityNotFound() {
+ doThrow(new ActivityNotFoundException()).when(mKeyChainMock).choosePrivateKeyAlias();
+
+ SSLClientCertificateRequest.maybeShowCertSelection(mKeyChainMock, mCallbackMock,
+ mFailureDialogMock);
+
+ verify(mKeyChainMock).choosePrivateKeyAlias();
+ verify(mCallbackMock).alias(null);
+ verify(mFailureDialogMock).show();
+ }
+
+ @Test
+ public void testSelectCertActivityFound() {
+ SSLClientCertificateRequest.maybeShowCertSelection(mKeyChainMock, mCallbackMock,
+ mFailureDialogMock);
+
+ verify(mKeyChainMock).choosePrivateKeyAlias();
+ verifyZeroInteractions(mFailureDialogMock);
+ }
+}
« no previous file with comments | « chrome/android/java/strings/android_chrome_strings.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698