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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/FocusedEditableTextFieldZoomTest.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser;
6
7 import static org.chromium.content.browser.test.util.CriteriaHelper.DEFAULT_POLL ING_INTERVAL;
8
9 import android.view.KeyEvent;
10
11 import org.chromium.base.test.util.DisabledTest;
12 import org.chromium.base.test.util.Feature;
13 import org.chromium.chrome.test.ChromeActivityTestCaseBase;
14 import org.chromium.chrome.test.util.TestHttpServerClient;
15 import org.chromium.content.browser.ContentViewCore;
16 import org.chromium.content.browser.test.util.Criteria;
17 import org.chromium.content.browser.test.util.CriteriaHelper;
18 import org.chromium.content.browser.test.util.DOMUtils;
19 import org.chromium.content.browser.test.util.KeyUtils;
20
21 public class FocusedEditableTextFieldZoomTest extends ChromeActivityTestCaseBase <ChromeActivity> {
22 private static final int TEST_TIMEOUT = 5000;
23 private static final String TEXTFIELD_DOM_ID = "textfield";
24 private static final float FLOAT_DELTA = 0.01f;
25 private static final float INITIAL_SCALE = 0.5f;
26
27 public FocusedEditableTextFieldZoomTest() {
28 super(ChromeActivity.class);
29 }
30
31 void waitForInitialZoom() throws InterruptedException {
32 // The zoom level sometimes changes immediately after the page loads whi ch makes grabbing
33 // the initial value problematic. We solve this by explicitly specifying the initial zoom
34 // level via the viewport tag and waiting for the zoom level to reach th at value before we
35 // proceed with the rest of the test.
36 final ContentViewCore contentViewCore = getActivity().getActivityTab().g etContentViewCore();
37 CriteriaHelper.pollForCriteria(new Criteria() {
38 @Override
39 public boolean isSatisfied() {
40 return contentViewCore.getScale() - INITIAL_SCALE < FLOAT_DELTA;
41 }
42 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL);
43 }
44
45 private void waitForZoomIn(final ContentViewCore contentViewCore, final floa t initialZoomLevel)
46 throws InterruptedException {
47 CriteriaHelper.pollForCriteria(new Criteria() {
48 @Override
49 public boolean isSatisfied() {
50 return contentViewCore.getScale() > initialZoomLevel;
51 }
52 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL);
53 }
54
55 @DisabledTest
56 @Feature({"TabContents"})
57 /*
58 * @LargeTest
59 * Broken by subpixel precision changes crbug.com/371119
60 */
61 public void testZoomInToSelected() throws Throwable {
62 // This should focus the text field and initiate a zoom in.
63 Tab tab = getActivity().getActivityTab();
64 final ContentViewCore contentViewCore = tab.getContentViewCore();
65 float initialZoomLevel = contentViewCore.getScale();
66
67 DOMUtils.clickNode(this, contentViewCore, TEXTFIELD_DOM_ID);
68
69 // Wait for the zoom in to complete.
70 waitForZoomIn(contentViewCore, initialZoomLevel);
71 }
72
73 @DisabledTest
74 @Feature({"TabContents"})
75 /*
76 * @LargeTest
77 * Broken by subpixel precision changes crbug.com/371119
78 */
79 public void testZoomOutOfSelectedIfOnlyBackPressed() throws Throwable {
80 final Tab tab = getActivity().getActivityTab();
81 final ContentViewCore contentViewCore = tab.getContentViewCore();
82 final float initialZoomLevel = contentViewCore.getScale();
83
84 // This should focus the text field and initiate a zoom in.
85 DOMUtils.clickNode(this, contentViewCore, TEXTFIELD_DOM_ID);
86
87 // Wait for the zoom in to complete.
88 waitForZoomIn(contentViewCore, initialZoomLevel);
89
90 KeyUtils.singleKeyEventView(getInstrumentation(), tab.getView(), KeyEven t.KEYCODE_BACK);
91
92 // We should zoom out to the previous zoom level.
93 CriteriaHelper.pollForCriteria(new Criteria() {
94 @Override
95 public boolean isSatisfied() {
96 return (contentViewCore.getScale() - initialZoomLevel) < FLOAT_D ELTA;
97 }
98 }, TEST_TIMEOUT, DEFAULT_POLLING_INTERVAL);
99 }
100
101 @Override
102 public void startMainActivity() throws InterruptedException {
103 startMainActivityWithURL(TestHttpServerClient.getUrl(
104 "chrome/test/data/android/focused_editable_zoom.html"));
105 waitForInitialZoom();
106 }
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698