Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2bc4ba4e authored by Aga Wronska's avatar Aga Wronska Committed by android-build-merger
Browse files

Merge "Go to root from child directory when root tapped. Bug: 27060001" into nyc-dev

am: 3b5a29cb

* commit '3b5a29cb':
  Go to root  from child directory when root tapped. Bug: 27060001
parents 1a2112c5 3b5a29cb
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -219,8 +219,8 @@ public abstract class BaseActivity extends Activity
    void onStackRestored(boolean restored, boolean external) {}
    void onStackRestored(boolean restored, boolean external) {}


    void onRootPicked(RootInfo root) {
    void onRootPicked(RootInfo root) {
        // Skip refreshing if root didn't change
        // Skip refreshing if root nor directory didn't change
        if(root.equals(getCurrentRoot())) {
        if (root.equals(getCurrentRoot()) && mState.stack.size() == 1) {
            return;
            return;
        }
        }


+51 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.documentsui;

import static com.android.documentsui.StubProvider.ROOT_0_ID;

import android.support.test.uiautomator.Configurator;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.test.InstrumentationTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.view.MotionEvent;

@LargeTest
public class RootUiTest extends ActivityTest<FilesActivity> {

    private static final String TAG = "RootUiTest";

    public RootUiTest() {
        super(FilesActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
        initTestFiles();
        bot.openRoot(ROOT_0_ID);
    }

    public void testRootTapped_GoToRootFromChildDir() throws Exception {
        bot.openDocument(dirName1);
        bot.assertWindowTitle(dirName1);
        bot.openRoot(ROOT_0_ID);
        bot.assertWindowTitle(ROOT_0_ID);
        assertDefaultContentOfTestDir0();
    }
}
+10 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import static junit.framework.Assert.assertFalse;
import android.content.Context;
import android.content.Context;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.By;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.BySelector;
import android.support.test.uiautomator.Configurator;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObject2;
import android.support.test.uiautomator.UiObject2;
@@ -32,6 +33,7 @@ import android.support.test.uiautomator.UiScrollable;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.UiSelector;
import android.support.test.uiautomator.Until;
import android.support.test.uiautomator.Until;
import android.util.Log;
import android.util.Log;
import android.view.MotionEvent;
import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodManager;


import junit.framework.Assert;
import junit.framework.Assert;
@@ -192,6 +194,14 @@ class UiBot {
        assertNotNull(getSnackbar(mContext.getString(id)));
        assertNotNull(getSnackbar(mContext.getString(id)));
    }
    }


    void openDocument(String label) throws UiObjectNotFoundException {
        int toolType = Configurator.getInstance().getToolType();
        Configurator.getInstance().setToolType(MotionEvent.TOOL_TYPE_FINGER);
        UiObject doc = findDocument(label);
        doc.click();
        Configurator.getInstance().setToolType(toolType);
    }

    void clickDocument(String label) throws UiObjectNotFoundException {
    void clickDocument(String label) throws UiObjectNotFoundException {
        findDocument(label).click();
        findDocument(label).click();
    }
    }