| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_TABLET; | 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_TABLET; |
| 8 | 8 |
| 9 import android.test.suitebuilder.annotation.MediumTest; | 9 import android.test.suitebuilder.annotation.MediumTest; |
| 10 import android.test.suitebuilder.annotation.Smoke; | 10 import android.test.suitebuilder.annotation.Smoke; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 import org.chromium.content.browser.test.util.CallbackHelper; | 28 import org.chromium.content.browser.test.util.CallbackHelper; |
| 29 import org.chromium.content.browser.test.util.Criteria; | 29 import org.chromium.content.browser.test.util.Criteria; |
| 30 import org.chromium.content.browser.test.util.CriteriaHelper; | 30 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 31 import org.chromium.content.browser.test.util.DOMUtils; | 31 import org.chromium.content.browser.test.util.DOMUtils; |
| 32 import org.chromium.content.browser.test.util.JavaScriptUtils; | 32 import org.chromium.content.browser.test.util.JavaScriptUtils; |
| 33 import org.chromium.content.browser.test.util.KeyUtils; | 33 import org.chromium.content.browser.test.util.KeyUtils; |
| 34 import org.chromium.content.browser.test.util.UiUtils; | 34 import org.chromium.content.browser.test.util.UiUtils; |
| 35 import org.chromium.net.test.util.TestWebServer; | 35 import org.chromium.net.test.util.TestWebServer; |
| 36 | 36 |
| 37 import java.net.URLEncoder; | 37 import java.net.URLEncoder; |
| 38 import java.util.Locale; |
| 38 import java.util.concurrent.Callable; | 39 import java.util.concurrent.Callable; |
| 39 import java.util.concurrent.ExecutionException; | 40 import java.util.concurrent.ExecutionException; |
| 40 import java.util.concurrent.Semaphore; | 41 import java.util.concurrent.Semaphore; |
| 41 import java.util.concurrent.TimeUnit; | 42 import java.util.concurrent.TimeUnit; |
| 42 import java.util.concurrent.TimeoutException; | 43 import java.util.concurrent.TimeoutException; |
| 43 import java.util.concurrent.atomic.AtomicBoolean; | 44 import java.util.concurrent.atomic.AtomicBoolean; |
| 44 | 45 |
| 45 /** | 46 /** |
| 46 * Navigate in UrlBar tests. | 47 * Navigate in UrlBar tests. |
| 47 */ | 48 */ |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 }; | 318 }; |
| 318 | 319 |
| 319 for (String url : urls) { | 320 for (String url : urls) { |
| 320 navigateAndObserve(url, url); | 321 navigateAndObserve(url, url); |
| 321 } | 322 } |
| 322 | 323 |
| 323 final int repeats = 3; | 324 final int repeats = 3; |
| 324 for (int i = 0; i < repeats; i++) { | 325 for (int i = 0; i < repeats; i++) { |
| 325 singleClickView(getActivity().findViewById(R.id.back_button)); | 326 singleClickView(getActivity().findViewById(R.id.back_button)); |
| 326 UiUtils.settleDownUI(getInstrumentation()); | 327 UiUtils.settleDownUI(getInstrumentation()); |
| 327 assertEquals(String.format( | 328 assertEquals(String.format(Locale.US, |
| 328 "URL mismatch after pressing back button for the 1st time in
repetition %d.", | 329 "URL mismatch after pressing back button for the 1st time in
repetition %d.", |
| 329 i), urls[1], getActivity().getActivityTab().getUrl()); | 330 i), urls[1], getActivity().getActivityTab().getUrl()); |
| 330 | 331 |
| 331 singleClickView(getActivity().findViewById(R.id.back_button)); | 332 singleClickView(getActivity().findViewById(R.id.back_button)); |
| 332 UiUtils.settleDownUI(getInstrumentation()); | 333 UiUtils.settleDownUI(getInstrumentation()); |
| 333 assertEquals(String.format( | 334 assertEquals(String.format(Locale.US, |
| 334 "URL mismatch after pressing back button for the 2nd time in
repetition %d.", | 335 "URL mismatch after pressing back button for the 2nd time in
repetition %d.", |
| 335 i), urls[0], getActivity().getActivityTab().getUrl()); | 336 i), urls[0], getActivity().getActivityTab().getUrl()); |
| 336 | 337 |
| 337 singleClickView(getActivity().findViewById(R.id.forward_button)); | 338 singleClickView(getActivity().findViewById(R.id.forward_button)); |
| 338 UiUtils.settleDownUI(getInstrumentation()); | 339 UiUtils.settleDownUI(getInstrumentation()); |
| 339 assertEquals(String.format( | 340 assertEquals(String.format(Locale.US, |
| 340 "URL mismatch after pressing fwd button for the 1st time in
repetition %d.", i), | 341 "URL mismatch after pressing fwd button for the 1st time in
repetition %d.", i), |
| 341 urls[1], getActivity().getActivityTab().getUrl()); | 342 urls[1], getActivity().getActivityTab().getUrl()); |
| 342 | 343 |
| 343 singleClickView(getActivity().findViewById(R.id.forward_button)); | 344 singleClickView(getActivity().findViewById(R.id.forward_button)); |
| 344 UiUtils.settleDownUI(getInstrumentation()); | 345 UiUtils.settleDownUI(getInstrumentation()); |
| 345 assertEquals(String.format( | 346 assertEquals(String.format(Locale.US, |
| 346 "URL mismatch after pressing fwd button for the 2nd time in
repetition %d.", i), | 347 "URL mismatch after pressing fwd button for the 2nd time in
repetition %d.", i), |
| 347 urls[2], getActivity().getActivityTab().getUrl()); | 348 urls[2], getActivity().getActivityTab().getUrl()); |
| 348 } | 349 } |
| 349 } | 350 } |
| 350 | 351 |
| 351 @MediumTest | 352 @MediumTest |
| 352 @Feature({"Navigation"}) | 353 @Feature({"Navigation"}) |
| 353 public void testWindowOpenUrlSpoof() throws Exception { | 354 public void testWindowOpenUrlSpoof() throws Exception { |
| 354 TestWebServer webServer = TestWebServer.start(); | 355 TestWebServer webServer = TestWebServer.start(); |
| 355 try { | 356 try { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 assert false : "Unexpected TimeoutException"; | 447 assert false : "Unexpected TimeoutException"; |
| 447 } | 448 } |
| 448 return null; | 449 return null; |
| 449 } | 450 } |
| 450 | 451 |
| 451 @Override | 452 @Override |
| 452 public void startMainActivity() throws InterruptedException { | 453 public void startMainActivity() throws InterruptedException { |
| 453 startMainActivityFromLauncher(); | 454 startMainActivityFromLauncher(); |
| 454 } | 455 } |
| 455 } | 456 } |
| OLD | NEW |