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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.media.AudioManager; | 8 import android.media.AudioManager; |
9 import android.support.test.filters.MediumTest; | 9 import android.support.test.filters.MediumTest; |
10 import android.support.test.filters.SmallTest; | 10 import android.support.test.filters.SmallTest; |
11 | 11 |
12 import org.chromium.base.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
13 import org.chromium.base.annotations.SuppressFBWarnings; | 13 import org.chromium.base.annotations.SuppressFBWarnings; |
14 import org.chromium.base.test.util.CommandLineFlags; | 14 import org.chromium.base.test.util.CommandLineFlags; |
15 import org.chromium.base.test.util.DisabledTest; | 15 import org.chromium.base.test.util.DisabledTest; |
16 import org.chromium.base.test.util.Feature; | 16 import org.chromium.base.test.util.Feature; |
17 import org.chromium.base.test.util.Restriction; | 17 import org.chromium.base.test.util.Restriction; |
18 import org.chromium.base.test.util.RetryOnFailure; | 18 import org.chromium.base.test.util.RetryOnFailure; |
19 import org.chromium.content.browser.test.util.Criteria; | 19 import org.chromium.content.browser.test.util.Criteria; |
20 import org.chromium.content.browser.test.util.CriteriaHelper; | 20 import org.chromium.content.browser.test.util.CriteriaHelper; |
21 import org.chromium.content.browser.test.util.DOMUtils; | 21 import org.chromium.content.browser.test.util.DOMUtils; |
| 22 import org.chromium.content.common.ContentSwitches; |
22 import org.chromium.content_public.browser.MediaSession; | 23 import org.chromium.content_public.browser.MediaSession; |
23 import org.chromium.content_public.browser.MediaSessionObserver; | 24 import org.chromium.content_public.browser.MediaSessionObserver; |
24 import org.chromium.content_shell_apk.ContentShellTestBase; | 25 import org.chromium.content_shell_apk.ContentShellTestBase; |
25 import org.chromium.media.MediaSwitches; | |
26 | 26 |
27 import java.util.ArrayList; | 27 import java.util.ArrayList; |
28 import java.util.concurrent.Callable; | 28 import java.util.concurrent.Callable; |
29 | 29 |
30 /** | 30 /** |
31 * Tests for MediaSession. | 31 * Tests for MediaSession. |
32 */ | 32 */ |
33 @RetryOnFailure | 33 @RetryOnFailure |
34 @CommandLineFlags.Add(MediaSwitches.IGNORE_AUTOPLAY_RESTRICTIONS_FOR_TESTS) | 34 @CommandLineFlags.Add(ContentSwitches.DISABLE_GESTURE_REQUIREMENT_FOR_MEDIA_PLAY
BACK) |
35 public class MediaSessionTest extends ContentShellTestBase { | 35 public class MediaSessionTest extends ContentShellTestBase { |
36 private static final String MEDIA_SESSION_TEST_URL = | 36 private static final String MEDIA_SESSION_TEST_URL = |
37 "content/test/data/media/session/media-session.html"; | 37 "content/test/data/media/session/media-session.html"; |
38 private static final String VERY_SHORT_AUDIO = "very-short-audio"; | 38 private static final String VERY_SHORT_AUDIO = "very-short-audio"; |
39 private static final String SHORT_AUDIO = "short-audio"; | 39 private static final String SHORT_AUDIO = "short-audio"; |
40 private static final String LONG_AUDIO = "long-audio"; | 40 private static final String LONG_AUDIO = "long-audio"; |
41 private static final String VERY_SHORT_VIDEO = "very-short-video"; | 41 private static final String VERY_SHORT_VIDEO = "very-short-video"; |
42 private static final String SHORT_VIDEO = "short-video"; | 42 private static final String SHORT_VIDEO = "short-video"; |
43 private static final String LONG_VIDEO = "long-video"; | 43 private static final String LONG_VIDEO = "long-video"; |
44 private static final String LONG_VIDEO_SILENT = "long-video-silent"; | 44 private static final String LONG_VIDEO_SILENT = "long-video-silent"; |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 481 |
482 mAudioFocusChangeListener.requestAudioFocus(AudioManager.AUDIOFOCUS_GAIN
); | 482 mAudioFocusChangeListener.requestAudioFocus(AudioManager.AUDIOFOCUS_GAIN
); |
483 assertEquals(AudioManager.AUDIOFOCUS_GAIN, mAudioFocusChangeListener.get
AudioFocusState()); | 483 assertEquals(AudioManager.AUDIOFOCUS_GAIN, mAudioFocusChangeListener.get
AudioFocusState()); |
484 | 484 |
485 // Wait for 1 second before observing MediaSession state change. | 485 // Wait for 1 second before observing MediaSession state change. |
486 Thread.sleep(AUDIO_FOCUS_CHANGE_TIMEOUT); | 486 Thread.sleep(AUDIO_FOCUS_CHANGE_TIMEOUT); |
487 | 487 |
488 assertEquals(expectedStates, mStateRecords); | 488 assertEquals(expectedStates, mStateRecords); |
489 } | 489 } |
490 } | 490 } |
OLD | NEW |