1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 5 * except in compliance with the License. You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software distributed under the 10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 11 * KIND, either express or implied. See the License for the specific language governing 12 * permissions and limitations under the License. 13 */ 14 15 package android.host.systemui; 16 17 /** 18 * Tests the differences in behavior between tiles in TileService#TILE_MODE_PASSIVE 19 * and TileService#TILE_MODE_ACTIVE. 20 */ 21 public class ActiveTileServiceTest extends BaseTileServiceTest { 22 // Constants for generating commands below. 23 private static final String SERVICE = "TestActiveTileService"; 24 25 private static final String ACTION_REQUEST_LISTENING = 26 "android.sysui.testtile.REQUEST_LISTENING"; 27 28 private static final String REQUEST_LISTENING = "am broadcast -a " + ACTION_REQUEST_LISTENING 29 + " " + PACKAGE; 30 31 public ActiveTileServiceTest() { 32 super(SERVICE); 33 } 34 35 public void testNotListening() throws Exception { 36 if (!supported()) return; 37 addTile(); 38 assertTrue(waitFor("onDestroy")); 39 40 // Open quick settings and verify that this service doesn't get put in 41 // a listening state since its an active tile. 42 openSettings(); 43 assertFalse(waitFor("onStartListening")); 44 } 45 46 public void testRequestListening() throws Exception { 47 if (!supported()) return; 48 addTile(); 49 assertTrue(waitFor("onDestroy")); 50 51 // Request the listening state and verify that it gets an onStartListening. 52 getDevice().executeShellCommand(REQUEST_LISTENING); 53 assertTrue(waitFor("requestListeningState")); 54 assertTrue(waitFor("onStartListening")); 55 } 56 57 public void testClick() throws Exception { 58 if (!supported()) return; 59 addTile(); 60 assertTrue(waitFor("onDestroy")); 61 62 // Open the quick settings. 63 openSettings(); 64 65 // Click on the tile and verify it happens. 66 clickTile(); 67 assertTrue(waitFor("onStartListening")); 68 assertTrue(waitFor("onClick")); 69 } 70 71 } 72