Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2018 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.telephony.embms.cts;
     18 
     19 import android.telephony.mbms.StreamingServiceInfo;
     20 import android.test.InstrumentationTestCase;
     21 
     22 import java.util.ArrayList;
     23 import java.util.Date;
     24 import java.util.HashMap;
     25 import java.util.List;
     26 import java.util.Locale;
     27 import java.util.Map;
     28 
     29 public class ServiceInfoTest extends InstrumentationTestCase {
     30     private static final String ID = "StreamingServiceId";
     31     private static final Map<Locale, String> LOCALE_DICT = new HashMap<Locale, String>() {{
     32         put(Locale.US, "Entertainment Source 1");
     33         put(Locale.CANADA, "Entertainment Source 1, eh?");
     34     }};
     35     private static final List<Locale> LOCALES = new ArrayList<Locale>() {{
     36         add(Locale.CANADA);
     37         add(Locale.US);
     38     }};
     39     private static final String NAME = "class1";
     40     private static final Date BEGIN_DATE = new Date(2017, 8, 21, 18, 20, 29);
     41     private static final Date END_DATE = new Date(2017, 8, 21, 18, 23, 9);
     42     private static final StreamingServiceInfo STREAMING_SERVICE_INFO =
     43         new StreamingServiceInfo(LOCALE_DICT, NAME, LOCALES, ID, BEGIN_DATE, END_DATE);
     44 
     45     public void testDataAccess() {
     46         assertEquals(LOCALES.size(), STREAMING_SERVICE_INFO.getLocales().size());
     47         for (int i = 0; i < LOCALES.size(); i++) {
     48             assertTrue(STREAMING_SERVICE_INFO.getLocales().contains(LOCALES.get(i)));
     49             assertTrue(LOCALES.contains(STREAMING_SERVICE_INFO.getLocales().get(i)));
     50         }
     51         assertEquals(LOCALE_DICT.size(), STREAMING_SERVICE_INFO.getNamedContentLocales().size());
     52         for (Locale l : STREAMING_SERVICE_INFO.getNamedContentLocales()) {
     53             assertTrue(LOCALE_DICT.containsKey(l));
     54             assertEquals(LOCALE_DICT.get(l), STREAMING_SERVICE_INFO.getNameForLocale(l).toString());
     55         }
     56 
     57         assertEquals(BEGIN_DATE, STREAMING_SERVICE_INFO.getSessionStartTime());
     58         assertEquals(END_DATE, STREAMING_SERVICE_INFO.getSessionEndTime());
     59         assertEquals(NAME, STREAMING_SERVICE_INFO.getServiceClassName());
     60     }
     61 }
     62