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.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
8 import android.view.KeyEvent; | 8 import android.view.KeyEvent; |
9 import android.view.View; | 9 import android.view.View; |
10 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 } | 420 } |
421 | 421 |
422 /** | 422 /** |
423 * Asserts that the keep screen on property in the given {@code view} is act
ive as | 423 * Asserts that the keep screen on property in the given {@code view} is act
ive as |
424 * {@code expected}. It also verifies that it is only active when the video
is playing. | 424 * {@code expected}. It also verifies that it is only active when the video
is playing. |
425 */ | 425 */ |
426 private void assertWaitForKeepScreenOnActive(final View view, final boolean
expected) | 426 private void assertWaitForKeepScreenOnActive(final View view, final boolean
expected) |
427 throws InterruptedException { | 427 throws InterruptedException { |
428 // We need to poll because it takes time to synchronize the state betwee
n the android | 428 // We need to poll because it takes time to synchronize the state betwee
n the android |
429 // views and Javascript. | 429 // views and Javascript. |
430 CriteriaHelper.pollForCriteria(new Criteria() { | 430 CriteriaHelper.pollInstrumentationThread(new Criteria() { |
431 @Override | 431 @Override |
432 public boolean isSatisfied() { | 432 public boolean isSatisfied() { |
433 try { | 433 try { |
434 return getKeepScreenOnOnInstrumentationThread(view) == expec
ted | 434 return getKeepScreenOnOnInstrumentationThread(view) == expec
ted |
435 && DOMUtils.isMediaPaused(getWebContentsOnUiThread()
, VIDEO_ID) | 435 && DOMUtils.isMediaPaused(getWebContentsOnUiThread()
, VIDEO_ID) |
436 != expected; | 436 != expected; |
437 } catch (InterruptedException | TimeoutException e) { | 437 } catch (InterruptedException | TimeoutException e) { |
438 fail(e.getMessage()); | 438 fail(e.getMessage()); |
439 return false; | 439 return false; |
440 } | 440 } |
(...skipping 30 matching lines...) Expand all Loading... |
471 if (getKeepScreenOnOnUiThread(viewGroup.getChildAt(i))) { | 471 if (getKeepScreenOnOnUiThread(viewGroup.getChildAt(i))) { |
472 return true; | 472 return true; |
473 } | 473 } |
474 } | 474 } |
475 } | 475 } |
476 return view.getKeepScreenOn(); | 476 return view.getKeepScreenOn(); |
477 } | 477 } |
478 | 478 |
479 private void assertWaitForIsFullscreen() throws InterruptedException { | 479 private void assertWaitForIsFullscreen() throws InterruptedException { |
480 // We need to poll because the Javascript state is updated asynchronousl
y | 480 // We need to poll because the Javascript state is updated asynchronousl
y |
481 CriteriaHelper.pollForCriteria(new Criteria() { | 481 CriteriaHelper.pollInstrumentationThread(new Criteria() { |
482 @Override | 482 @Override |
483 public boolean isSatisfied() { | 483 public boolean isSatisfied() { |
484 try { | 484 try { |
485 return DOMUtils.isFullscreen(getWebContentsOnUiThread()); | 485 return DOMUtils.isFullscreen(getWebContentsOnUiThread()); |
486 } catch (InterruptedException | TimeoutException e) { | 486 } catch (InterruptedException | TimeoutException e) { |
487 fail(e.getMessage()); | 487 fail(e.getMessage()); |
488 return false; | 488 return false; |
489 } | 489 } |
490 } | 490 } |
491 }); | 491 }); |
492 } | 492 } |
493 | 493 |
494 private void assertWaitForIsEmbedded() throws InterruptedException { | 494 private void assertWaitForIsEmbedded() throws InterruptedException { |
495 // We need to poll because the Javascript state is updated asynchronousl
y | 495 // We need to poll because the Javascript state is updated asynchronousl
y |
496 CriteriaHelper.pollForCriteria(new Criteria() { | 496 CriteriaHelper.pollInstrumentationThread(new Criteria() { |
497 @Override | 497 @Override |
498 public boolean isSatisfied() { | 498 public boolean isSatisfied() { |
499 try { | 499 try { |
500 return !DOMUtils.isFullscreen(getWebContentsOnUiThread()); | 500 return !DOMUtils.isFullscreen(getWebContentsOnUiThread()); |
501 } catch (InterruptedException | TimeoutException e) { | 501 } catch (InterruptedException | TimeoutException e) { |
502 fail(e.getMessage()); | 502 fail(e.getMessage()); |
503 return false; | 503 return false; |
504 } | 504 } |
505 } | 505 } |
506 }); | 506 }); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 public WebContents call() throws Exception { | 561 public WebContents call() throws Exception { |
562 return mContentViewCore.getWebContents(); | 562 return mContentViewCore.getWebContents(); |
563 } | 563 } |
564 }); | 564 }); |
565 } catch (Exception e) { | 565 } catch (Exception e) { |
566 fail(e.getMessage()); | 566 fail(e.getMessage()); |
567 return null; | 567 return null; |
568 } | 568 } |
569 } | 569 } |
570 } | 570 } |
OLD | NEW |