• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.platform.test.helpers;
18 
19 import android.app.Instrumentation;
20 
21 public abstract class AbstractYouTubeHelper extends AbstractStandardAppHelper {
22 
23     public enum VideoQuality {
24         QUALITY_AUTO ("Auto"),
25         QUALITY_144p ("144p"),
26         QUALITY_240p ("240p"),
27         QUALITY_360p ("360p"),
28         QUALITY_480p ("480p"),
29         QUALITY_720p ("720p"),
30         QUALITY_1080p("1080p");
31 
32         private final String text;
33 
VideoQuality(String text)34         VideoQuality(String text) {
35             this.text = text;
36         }
37 
getText()38         public String getText() {
39             return text;
40         }
41     };
42 
AbstractYouTubeHelper(Instrumentation instr)43     public AbstractYouTubeHelper(Instrumentation instr) {
44         super(instr);
45     }
46 
47     /**
48      * Setup expectations: YouTube app is open.
49      *
50      * This method keeps pressing the back button until YouTube is on the home page.
51      */
goToHomePage()52     public abstract void goToHomePage();
53 
54     /**
55      * Setup expectations: YouTube is on the home page.
56      *
57      * This method scrolls to the top of the home page and clicks the search button.
58      */
goToSearchPage()59     public abstract void goToSearchPage();
60 
61     /**
62      * Setup expectations: YouTube is on the non-fullscreen video player page.
63      *
64      * This method changes the video player to fullscreen mode. Has no effect if the video player
65      * is already in fullscreen mode.
66      */
goToFullscreenMode()67     public abstract void goToFullscreenMode();
68 
69     /**
70      * Setup expectations: YouTube is on the home page.
71      *
72      * This method selects a video on the home page and blocks until the video is playing.
73      */
playHomePageVideo()74     public abstract void playHomePageVideo();
75 
76     /**
77      * Setup expectations: YouTube is on the search results page.
78      *
79      * This method selects a search result video and blocks until the video is playing.
80      */
playSearchResultPageVideo()81     public abstract void playSearchResultPageVideo();
82 
83     /**
84      * Setup expectations: Recently opened a video in the YouTube app.
85      *
86      * This method blocks until the video has loaded.
87      *
88      * @param timeout wait timeout in milliseconds
89      * @return true if video loaded within the timeout, false otherwise
90      */
waitForVideoToLoad(long timeout)91     public abstract boolean waitForVideoToLoad(long timeout);
92 
93     /**
94      * Setup expectations: Recently initiated a search query in the YouTube app.
95      *
96      * This method blocks until search results appear.
97      *
98      * @param timeout wait timeout in milliseconds
99      * @return true if search results appeared within timeout, false otherwise
100      */
waitForSearchResults(long timeout)101     public abstract boolean waitForSearchResults(long timeout);
102 
103     /**
104      * Setup expectations: YouTube is on the video player page.
105      *
106      * This method changes the video quality of the current video.
107      *
108      * @param quality   the desired video quality
109      * @see AbstractYouTubeHelper.VideoQuality
110      */
setVideoQuality(VideoQuality quality)111     public abstract void setVideoQuality(VideoQuality quality);
112 
113     /**
114      * Setup expectations: YouTube is on the video player page.
115      *
116      * This method resumes the video if it is paused.
117      */
resumeVideo()118     public abstract void resumeVideo();
119 }
120