| 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 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
| 6 | 6 |
| 7 import android.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
| 8 import android.util.Pair; | 8 import android.util.Pair; |
| 9 | 9 |
| 10 import org.chromium.android_webview.AwContents; | 10 import org.chromium.android_webview.AwContents; |
| 11 import org.chromium.android_webview.test.TestAwContentsClient.OnReceivedLoginReq
uestHelper; | 11 import org.chromium.android_webview.test.TestAwContentsClient.OnReceivedLoginReq
uestHelper; |
| 12 import org.chromium.base.test.util.Feature; | 12 import org.chromium.base.test.util.Feature; |
| 13 import org.chromium.net.test.util.TestWebServer; | 13 import org.chromium.net.test.util.TestWebServer; |
| 14 | 14 |
| 15 import java.util.ArrayList; | 15 import java.util.ArrayList; |
| 16 import java.util.List; | 16 import java.util.List; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Tests for the AwContentsClient.onReceivedLoginRequest callback. | 19 * Tests for the AwContentsClient.onReceivedLoginRequest callback. |
| 20 */ | 20 */ |
| 21 public class AwContentsClientAutoLoginTest extends AwTestBase { | 21 public class AwContentsClientAutoLoginTest extends AwTestBase { |
| 22 private TestAwContentsClient mContentsClient = new TestAwContentsClient(); | 22 private TestAwContentsClient mContentsClient = new TestAwContentsClient(); |
| 23 | 23 |
| 24 private void autoLoginTestHelper(final String testName, final String xAutoLo
ginHeader, | 24 private void autoLoginTestHelper(final String testName, final String xAutoLo
ginHeader, |
| 25 final String expectedRealm, final String expectedAccount, final Stri
ng expectedArgs) | 25 final String expectedRealm, final String expectedAccount, final Stri
ng expectedArgs) |
| 26 throws Throwable { | 26 throws Throwable { |
| 27 AwTestContainerView testView = createAwTestContainerViewOnMainSync(mCont
entsClient); | 27 AwTestContainerView testView = createAwTestContainerViewOnMainSync(mCont
entsClient); |
| 28 AwContents awContents = testView.getAwContents(); | 28 AwContents awContents = testView.getAwContents(); |
| 29 final OnReceivedLoginRequestHelper loginRequestHelper = | 29 final OnReceivedLoginRequestHelper loginRequestHelper = |
| 30 mContentsClient.getOnReceivedLoginRequestHelper(); | 30 mContentsClient.getOnReceivedLoginRequestHelper(); |
| 31 | 31 |
| 32 final String path = "/" + testName + ".html"; | 32 final String path = "/" + testName + ".html"; |
| 33 final String html = testName; | 33 final String html = testName; |
| 34 List<Pair<String, String>> headers = new ArrayList<Pair<String, String>>
(); | 34 List<Pair<String, String>> headers = new ArrayList<Pair<String, String>>
(); |
| 35 headers.add(Pair.create("x-auto-login", xAutoLoginHeader)); | 35 headers.add(Pair.create("x-auto-login", xAutoLoginHeader)); |
| 36 | 36 |
| 37 TestWebServer webServer = TestWebServer.start(); | 37 TestWebServer webServer = TestWebServer.start(); |
| 38 try { | 38 try { |
| 39 final String pageUrl = webServer.setResponse(path, html, headers); | 39 final String pageUrl = webServer.setResponse(path, html, headers); |
| 40 final int callCount = loginRequestHelper.getCallCount(); | 40 final int callCount = loginRequestHelper.getCallCount(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 @SmallTest | 76 @SmallTest |
| 77 public void testAutoLoginOnNonGoogle() throws Throwable { | 77 public void testAutoLoginOnNonGoogle() throws Throwable { |
| 78 autoLoginTestHelper( | 78 autoLoginTestHelper( |
| 79 "testAutoLoginOnGoogleCom", /* testName */ | 79 "testAutoLoginOnGoogleCom", /* testName */ |
| 80 "realm=com.bar&account=foo%40bar.com&args=args", /* xAutoLoginHe
ader */ | 80 "realm=com.bar&account=foo%40bar.com&args=args", /* xAutoLoginHe
ader */ |
| 81 "com.bar", /* expectedRealm */ | 81 "com.bar", /* expectedRealm */ |
| 82 "foo@bar.com", /* expectedAccount */ | 82 "foo@bar.com", /* expectedAccount */ |
| 83 "args" /* expectedArgs */); | 83 "args" /* expectedArgs */); |
| 84 } | 84 } |
| 85 } | 85 } |
| OLD | NEW |