OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.media.remote; | 5 package org.chromium.chrome.browser.media.remote; |
6 | 6 |
7 import android.app.Dialog; | 7 import android.app.Dialog; |
8 import android.app.Instrumentation; | 8 import android.app.Instrumentation; |
9 import android.graphics.Rect; | 9 import android.graphics.Rect; |
10 import android.os.SystemClock; | 10 import android.os.SystemClock; |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 Rect fullscreenButton = fullscreenButton(videoRect); | 525 Rect fullscreenButton = fullscreenButton(videoRect); |
526 int right = fullscreenButton.left - BUTTON_RIGHT_MARGIN - FULLSCREEN_BUT
TON_LEFT_MARGIN; | 526 int right = fullscreenButton.left - BUTTON_RIGHT_MARGIN - FULLSCREEN_BUT
TON_LEFT_MARGIN; |
527 int left = right - BUTTON_WIDTH; | 527 int left = right - BUTTON_WIDTH; |
528 return new Rect(left, fullscreenButton.top, right, fullscreenButton.bott
om); | 528 return new Rect(left, fullscreenButton.top, right, fullscreenButton.bott
om); |
529 } | 529 } |
530 | 530 |
531 private void tapButton(Tab tab, Rect rect) { | 531 private void tapButton(Tab tab, Rect rect) { |
532 ContentViewCore core = tab.getContentViewCore(); | 532 ContentViewCore core = tab.getContentViewCore(); |
533 int clickX = | 533 int clickX = |
534 (int) core.getRenderCoordinates().fromLocalCssToPix( | 534 (int) core.getRenderCoordinates().fromLocalCssToPix( |
535 ((float) (rect.left + rect.right)) / 2) | 535 ((float) (rect.left + rect.right)) / 2); |
536 + core.getViewportSizeOffsetWidthPix(); | |
537 int clickY = | 536 int clickY = |
538 (int) core.getRenderCoordinates().fromLocalCssToPix( | 537 (int) core.getRenderCoordinates().fromLocalCssToPix( |
539 ((float) (rect.top + rect.bottom)) / 2) | 538 ((float) (rect.top + rect.bottom)) / 2) |
540 + core.getViewportSizeOffsetHeightPix(); | 539 + core.getTopControlsHeightPix(); |
541 // Click using a virtual mouse, since a touch may result in a disambigua
tion pop-up. | 540 // Click using a virtual mouse, since a touch may result in a disambigua
tion pop-up. |
542 mouseSingleClickView(getInstrumentation(), tab.getView(), clickX, clickY
); | 541 mouseSingleClickView(getInstrumentation(), tab.getView(), clickX, clickY
); |
543 } | 542 } |
544 | 543 |
545 private static void sendMouseAction(Instrumentation instrumentation, int act
ion, long downTime, | 544 private static void sendMouseAction(Instrumentation instrumentation, int act
ion, long downTime, |
546 float x, float y) { | 545 float x, float y) { |
547 long eventTime = SystemClock.uptimeMillis(); | 546 long eventTime = SystemClock.uptimeMillis(); |
548 MotionEvent.PointerCoords coords[] = new MotionEvent.PointerCoords[1]; | 547 MotionEvent.PointerCoords coords[] = new MotionEvent.PointerCoords[1]; |
549 coords[0] = new MotionEvent.PointerCoords(); | 548 coords[0] = new MotionEvent.PointerCoords(); |
550 coords[0].x = x; | 549 coords[0].x = x; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 * @param instrumentation Instrumentation object used by the test. | 593 * @param instrumentation Instrumentation object used by the test. |
595 * @param v The view the coordinates are relative to. | 594 * @param v The view the coordinates are relative to. |
596 */ | 595 */ |
597 private static void mouseSingleClickView(Instrumentation instrumentation, Vi
ew v) { | 596 private static void mouseSingleClickView(Instrumentation instrumentation, Vi
ew v) { |
598 int x = v.getWidth() / 2; | 597 int x = v.getWidth() / 2; |
599 int y = v.getHeight() / 2; | 598 int y = v.getHeight() / 2; |
600 mouseSingleClickView(instrumentation, v, x, y); | 599 mouseSingleClickView(instrumentation, v, x, y); |
601 } | 600 } |
602 | 601 |
603 } | 602 } |
OLD | NEW |