Home | History | Annotate | Download | only in base
      1 /*
      2  * Copyright (C) 2016 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.documentsui.base;
     18 
     19 
     20 import static org.junit.Assert.assertArrayEquals;
     21 
     22 import android.content.Intent;
     23 import android.support.test.filters.SmallTest;
     24 import android.support.test.runner.AndroidJUnit4;
     25 
     26 import org.junit.Before;
     27 import org.junit.Test;
     28 import org.junit.runner.RunWith;
     29 
     30 @RunWith(AndroidJUnit4.class)
     31 @SmallTest
     32 public class StateTest {
     33 
     34     private static final String[] MIME_TYPES = { "image/gif", "image/jpg" };
     35 
     36     private Intent mIntent;
     37     private State mState;
     38 
     39     @Before
     40     public void setUp() {
     41         mIntent = new Intent();
     42         mState = new State();
     43     }
     44 
     45     @Test
     46     public void testAcceptGivenMimeTypesInExtra() {
     47         mIntent.putExtra(Intent.EXTRA_MIME_TYPES, MIME_TYPES);
     48 
     49         mState.initAcceptMimes(mIntent, "*/*");
     50 
     51         assertArrayEquals(MIME_TYPES, mState.acceptMimes);
     52     }
     53 
     54     @Test
     55     public void testAcceptIntentTypeWithoutExtra() {
     56         mState.initAcceptMimes(mIntent, MIME_TYPES[0]);
     57 
     58         assertArrayEquals(new String[] { MIME_TYPES[0] }, mState.acceptMimes);
     59     }
     60 }
     61