1 /* 2 * Copyright (C) 2019 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 com.android.cts.verifier.qstiles; 18 19 import android.content.ComponentName; 20 import android.view.View; 21 import android.view.ViewGroup; 22 23 import com.android.cts.verifier.R; 24 25 import java.util.ArrayList; 26 import java.util.List; 27 28 public class TileServiceVerifierActivity extends InteractiveVerifierActivity implements Runnable { 29 30 @Override getTitleResource()31 protected int getTitleResource() { 32 return R.string.tiles_test; 33 } 34 35 @Override getInstructionsResource()36 protected int getInstructionsResource() { 37 return R.string.tiles_info; 38 } 39 40 @Override getTileComponentName()41 protected ComponentName getTileComponentName() { 42 String tilePath = "com.android.cts.verifier/" 43 + "com.android.cts.verifier.qstiles.MockTileService"; 44 return ComponentName.unflattenFromString(tilePath); 45 } 46 47 @Override createTestItems()48 protected List<InteractiveTestCase> createTestItems() { 49 ArrayList<InteractiveTestCase> list = new ArrayList<>(); 50 list.add(new SettingUpTile()); 51 list.add(new TileNotAvailable()); 52 list.add(new TileInCustomizer()); 53 list.add(new TearingDownTile()); 54 return list; 55 } 56 57 private class SettingUpTile extends InteractiveTestCase { 58 59 @Override inflate(ViewGroup parent)60 protected View inflate(ViewGroup parent) { 61 return createAutoItem(parent, R.string.tiles_adding_tile); 62 } 63 64 @Override test()65 protected void test() { 66 boolean result = setTileState(true); 67 if (result) { 68 status = PASS; 69 } else { 70 setFailed("Tile Service failed to enable"); 71 } 72 } 73 } 74 75 // Tests 76 private class TileNotAvailable extends InteractiveTestCase { 77 @Override inflate(ViewGroup parent)78 protected View inflate(ViewGroup parent) { 79 return createUserPassFail(parent, R.string.tiles_not_added); 80 81 } 82 83 @Override test()84 protected void test() { 85 status = WAIT_FOR_USER; 86 next(); 87 } 88 } 89 90 // Tests 91 private class TileInCustomizer extends InteractiveTestCase { 92 @Override inflate(ViewGroup parent)93 protected View inflate(ViewGroup parent) { 94 return createUserPassFail(parent, R.string.tiles_in_customizer); 95 96 } 97 98 @Override test()99 protected void test() { 100 status = WAIT_FOR_USER; 101 next(); 102 } 103 } 104 105 private class TearingDownTile extends InteractiveTestCase { 106 107 @Override inflate(ViewGroup parent)108 protected View inflate(ViewGroup parent) { 109 return createAutoItem(parent, R.string.tiles_removing_tile); 110 } 111 112 @Override test()113 protected void test() { 114 boolean result = setTileState(false); 115 if (result) { 116 status = PASS; 117 } else { 118 setFailed("Tile Service failed to disable"); 119 } 120 } 121 } 122 } 123