Home | History | Annotate | Download | only in documentsui
      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 package com.android.documentsui;
     17 
     18 import android.content.Intent;
     19 import android.net.Uri;
     20 import android.provider.DocumentsContract;
     21 
     22 import com.android.documentsui.bots.UiBot;
     23 import com.android.documentsui.inspector.InspectorActivity;
     24 
     25 public class InspectorUiTest extends ActivityTest<InspectorActivity> {
     26 
     27     private static final String TEST_DOC_NAME = "test.txt";
     28 
     29     public InspectorUiTest() {
     30         super(InspectorActivity.class);
     31     }
     32 
     33     @Override
     34     public void setUp() throws Exception {
     35         super.setUp();
     36     }
     37 
     38     @Override
     39     public void launchActivity() {
     40         if (!features.isInspectorEnabled()) {
     41             return;
     42         }
     43         final Intent intent = context.getPackageManager().getLaunchIntentForPackage(
     44                 UiBot.TARGET_PKG);
     45         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
     46         Uri uri = DocumentsContract.buildDocumentUri(InspectorProvider.AUTHORITY, TEST_DOC_NAME);
     47         intent.setData(uri);
     48         setActivityIntent(intent);
     49         getActivity();
     50     }
     51 
     52     public void testDisplayFileName() throws Exception {
     53         if (!features.isInspectorEnabled()) {
     54             return;
     55         }
     56         bots.inspector.assertTitle("test.txt");
     57     }
     58 
     59     public void testDisplayFileType() throws Exception {
     60         if (!features.isInspectorEnabled()) {
     61             return;
     62         }
     63         bots.inspector.assertRowPresent(getActivity().getString(R.string.sort_dimension_file_type),
     64                 "vnd.android.document/directory", getActivity());
     65     }
     66 }
     67