• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.tv.testing;
18 
19 import android.support.annotation.Nullable;
20 import com.android.tv.data.ChannelNumber;
21 import com.google.common.truth.ComparableSubject;
22 import com.google.common.truth.FailureMetadata;
23 import com.google.common.truth.Subject;
24 import com.google.common.truth.Truth;
25 
26 /** Propositions for {@link ChannelNumber} subjects. */
27 public final class ChannelNumberSubject
28         extends ComparableSubject<ChannelNumberSubject, ChannelNumber> {
29     private static final Subject.Factory<ChannelNumberSubject, ChannelNumber> FACTORY =
30             ChannelNumberSubject::new;
31 
channelNumbers()32     public static Subject.Factory<ChannelNumberSubject, ChannelNumber> channelNumbers() {
33         return FACTORY;
34     }
35 
assertThat(@ullable ChannelNumber actual)36     public static ChannelNumberSubject assertThat(@Nullable ChannelNumber actual) {
37         return Truth.assertAbout(channelNumbers()).that(actual);
38     }
39 
ChannelNumberSubject(FailureMetadata failureMetadata, @Nullable ChannelNumber subject)40     public ChannelNumberSubject(FailureMetadata failureMetadata, @Nullable ChannelNumber subject) {
41         super(failureMetadata, subject);
42     }
43 
displaysAs(int major)44     public void displaysAs(int major) {
45         if (!getSubject().majorNumber.equals(Integer.toString(major))
46                 || getSubject().hasDelimiter) {
47             fail("displaysAs", major);
48         }
49     }
50 
displaysAs(int major, int minor)51     public void displaysAs(int major, int minor) {
52         if (!getSubject().majorNumber.equals(Integer.toString(major))
53                 || !getSubject().minorNumber.equals(Integer.toString(minor))
54                 || !getSubject().hasDelimiter) {
55             fail("displaysAs", major + "-" + minor);
56         }
57     }
58 
isEmpty()59     public void isEmpty() {
60         if (!getSubject().majorNumber.isEmpty()
61                 || !getSubject().minorNumber.isEmpty()
62                 || getSubject().hasDelimiter) {
63             fail("isEmpty");
64         }
65     }
66 }
67