blob: 99d0ae01eb001b22f33bdde8ddbc453388a30947 [file] [log] [blame]
Julian Mancinidb28d842017-06-19 10:14:57 -07001/*
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 */
16package com.android.documentsui;
17
18import android.content.Intent;
19import android.net.Uri;
20import android.provider.DocumentsContract;
Brett Chabot2027ca02018-12-13 19:06:31 -080021
22import androidx.test.filters.LargeTest;
Julian Mancinidb28d842017-06-19 10:14:57 -070023
24import com.android.documentsui.bots.UiBot;
Steve McKayf433d202017-07-12 18:46:09 -070025import com.android.documentsui.inspector.InspectorActivity;
Julian Mancinidb28d842017-06-19 10:14:57 -070026
Steve McKayefd10ac2017-07-25 13:33:57 -070027@LargeTest
Steve McKayf433d202017-07-12 18:46:09 -070028public class InspectorUiTest extends ActivityTest<InspectorActivity> {
Julian Mancinidb28d842017-06-19 10:14:57 -070029
30 private static final String TEST_DOC_NAME = "test.txt";
31
32 public InspectorUiTest() {
Steve McKayf433d202017-07-12 18:46:09 -070033 super(InspectorActivity.class);
Julian Mancinidb28d842017-06-19 10:14:57 -070034 }
35
36 @Override
37 public void setUp() throws Exception {
38 super.setUp();
39 }
40
41 @Override
42 public void launchActivity() {
43 if (!features.isInspectorEnabled()) {
44 return;
45 }
46 final Intent intent = context.getPackageManager().getLaunchIntentForPackage(
Bill Lin34329192019-03-05 22:22:20 +080047 UiBot.targetPackageName);
Julian Mancinidb28d842017-06-19 10:14:57 -070048 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
49 Uri uri = DocumentsContract.buildDocumentUri(InspectorProvider.AUTHORITY, TEST_DOC_NAME);
50 intent.setData(uri);
51 setActivityIntent(intent);
52 getActivity();
53 }
54
55 public void testDisplayFileName() throws Exception {
56 if (!features.isInspectorEnabled()) {
57 return;
58 }
59 bots.inspector.assertTitle("test.txt");
60 }
61
Steve McKay99373462017-08-04 15:17:08 -070062 public void testFolderDetails() throws Exception {
Julian Mancinidb28d842017-06-19 10:14:57 -070063 if (!features.isInspectorEnabled()) {
64 return;
65 }
Steve McKay99373462017-08-04 15:17:08 -070066 bots.inspector.assertRowEquals(
Steve McKayefd10ac2017-07-25 13:33:57 -070067 getActivity().getString(R.string.sort_dimension_file_type),
68 "Folder",
69 getActivity());
Steve McKay99373462017-08-04 15:17:08 -070070 bots.inspector.assertRowEquals(
71 getActivity().getString(R.string.directory_items),
Jackal Guo8e01a452018-06-21 18:19:17 +080072 InspectorProvider.NUMBER_OF_ITEMS,
Steve McKay99373462017-08-04 15:17:08 -070073 getActivity());
Julian Mancinidb28d842017-06-19 10:14:57 -070074 }
75}