2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 package com.android.systemui.phone;
19 import com.android.systemui.statusbar.phone.DozeParameters.IntInOutMatcher;
21 import android.test.AndroidTestCase;
22 import android.test.suitebuilder.annotation.SmallTest;
25 public class DozeParametersTests extends AndroidTestCase {
27 public void test_inOutMatcher_defaultIn() {
28 IntInOutMatcher intInOutMatcher = new IntInOutMatcher("*");
30 assertTrue(intInOutMatcher.isIn(1));
31 assertTrue(intInOutMatcher.isIn(-1));
32 assertTrue(intInOutMatcher.isIn(0));
35 public void test_inOutMatcher_defaultOut() {
36 IntInOutMatcher intInOutMatcher = new IntInOutMatcher("!*");
38 assertFalse(intInOutMatcher.isIn(1));
39 assertFalse(intInOutMatcher.isIn(-1));
40 assertFalse(intInOutMatcher.isIn(0));
43 public void test_inOutMatcher_someIn() {
44 IntInOutMatcher intInOutMatcher = new IntInOutMatcher("1,2,3,!*");
46 assertTrue(intInOutMatcher.isIn(1));
47 assertTrue(intInOutMatcher.isIn(2));
48 assertTrue(intInOutMatcher.isIn(3));
50 assertFalse(intInOutMatcher.isIn(0));
51 assertFalse(intInOutMatcher.isIn(4));
54 public void test_inOutMatcher_someOut() {
55 IntInOutMatcher intInOutMatcher = new IntInOutMatcher("!1,!2,!3,*");
57 assertFalse(intInOutMatcher.isIn(1));
58 assertFalse(intInOutMatcher.isIn(2));
59 assertFalse(intInOutMatcher.isIn(3));
61 assertTrue(intInOutMatcher.isIn(0));
62 assertTrue(intInOutMatcher.isIn(4));
65 public void test_inOutMatcher_mixed() {
66 IntInOutMatcher intInOutMatcher = new IntInOutMatcher("!1,2,!3,*");
68 assertFalse(intInOutMatcher.isIn(1));
69 assertTrue(intInOutMatcher.isIn(2));
70 assertFalse(intInOutMatcher.isIn(3));
72 assertTrue(intInOutMatcher.isIn(0));
73 assertTrue(intInOutMatcher.isIn(4));
76 public void test_inOutMatcher_failEmpty() {
78 new IntInOutMatcher("");
79 fail("Expected IllegalArgumentException");
80 } catch (IllegalArgumentException e) {
85 public void test_inOutMatcher_failNull() {
87 new IntInOutMatcher(null);
88 fail("Expected IllegalArgumentException");
89 } catch (IllegalArgumentException e) {
94 public void test_inOutMatcher_failEmptyClause() {
96 new IntInOutMatcher("!1,*,");
97 fail("Expected IllegalArgumentException");
98 } catch (IllegalArgumentException e) {
103 public void test_inOutMatcher_failDuplicate() {
105 new IntInOutMatcher("!1,*,!1");
106 fail("Expected IllegalArgumentException");
107 } catch (IllegalArgumentException e) {
112 public void test_inOutMatcher_failDuplicateDefault() {
114 new IntInOutMatcher("!1,*,*");
115 fail("Expected IllegalArgumentException");
116 } catch (IllegalArgumentException e) {
121 public void test_inOutMatcher_failMalformedNot() {
123 new IntInOutMatcher("!,*");
124 fail("Expected IllegalArgumentException");
125 } catch (IllegalArgumentException e) {
130 public void test_inOutMatcher_failText() {
132 new IntInOutMatcher("!abc,*");
133 fail("Expected IllegalArgumentException");
134 } catch (IllegalArgumentException e) {
139 public void test_inOutMatcher_failContradiction() {
141 new IntInOutMatcher("1,!1,*");
142 fail("Expected IllegalArgumentException");
143 } catch (IllegalArgumentException e) {
148 public void test_inOutMatcher_failContradictionDefault() {
150 new IntInOutMatcher("1,*,!*");
151 fail("Expected IllegalArgumentException");
152 } catch (IllegalArgumentException e) {
157 public void test_inOutMatcher_failMissingDefault() {
159 new IntInOutMatcher("1");
160 fail("Expected IllegalArgumentException");
161 } catch (IllegalArgumentException e) {