2017-04-29 17:08:15 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Martijn Brekhof. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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 org.xbmc.kore.tests.ui;
|
|
|
|
|
|
|
|
import android.support.test.espresso.Espresso;
|
|
|
|
|
|
|
|
import org.junit.Ignore;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.xbmc.kore.R;
|
|
|
|
import org.xbmc.kore.testhelpers.EspressoTestUtils;
|
2017-07-17 20:07:11 +02:00
|
|
|
import org.xbmc.kore.testhelpers.Utils;
|
2017-04-29 17:08:15 +02:00
|
|
|
import org.xbmc.kore.ui.BaseMediaActivity;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
|
import static org.junit.Assert.assertTrue;
|
2017-07-17 20:07:11 +02:00
|
|
|
import static org.xbmc.kore.testhelpers.EspressoTestUtils.clickAdapterViewItem;
|
|
|
|
import static org.xbmc.kore.testhelpers.EspressoTestUtils.rotateDevice;
|
2017-04-29 17:08:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains generic tests for all activities extending BaseMediaActivity
|
|
|
|
* @param <T>
|
|
|
|
*/
|
|
|
|
@Ignore
|
|
|
|
abstract public class BaseMediaActivityTests<T extends BaseMediaActivity> extends AbstractTestClass<T> {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if the initial state shows the hamburger icon
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void showHamburgerInInitialState() {
|
|
|
|
assertFalse(getActivity().getDrawerIndicatorIsArrow());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if navigation icon is changed to an arrow when selecting a list item
|
|
|
|
*
|
|
|
|
* UI interaction flow tested:
|
|
|
|
* 1. Click on list item
|
|
|
|
* 2. Result: navigation icon should be an arrow
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void showArrowWhenSelectingListItem() {
|
2017-07-17 20:07:11 +02:00
|
|
|
clickAdapterViewItem(0, R.id.list);
|
2017-04-29 17:08:15 +02:00
|
|
|
|
|
|
|
assertTrue(((T) EspressoTestUtils.getActivity()).getDrawerIndicatorIsArrow());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if navigation icon is changed to an arrow when selecting a list item
|
|
|
|
*
|
|
|
|
* UI interaction flow tested:
|
|
|
|
* 1. Click on list item
|
|
|
|
* 2. Press back
|
|
|
|
* 3. Result: navigation icon should be a hamburger
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void showHamburgerWhenSelectingListItemAndReturn() {
|
2017-07-17 20:07:11 +02:00
|
|
|
clickAdapterViewItem(0, R.id.list);
|
2017-04-29 17:08:15 +02:00
|
|
|
Espresso.pressBack();
|
|
|
|
|
|
|
|
assertFalse(((T) EspressoTestUtils.getActivity()).getDrawerIndicatorIsArrow());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if navigation icon is restored to an arrow when selecting a list item
|
|
|
|
* and rotating the device
|
|
|
|
*
|
|
|
|
* UI interaction flow tested:
|
|
|
|
* 1. Click on list item
|
|
|
|
* 2. Rotate device
|
|
|
|
* 3. Result: navigation icon should be an arrow
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void restoreArrowOnConfigurationChange() {
|
2017-07-17 20:07:11 +02:00
|
|
|
clickAdapterViewItem(0, R.id.list);
|
|
|
|
rotateDevice(getActivity());
|
2017-04-29 17:08:15 +02:00
|
|
|
|
|
|
|
assertTrue(((T) EspressoTestUtils.getActivity()).getDrawerIndicatorIsArrow());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test if navigation icon is restored to an hamburger when selecting a list item
|
|
|
|
* and rotating the device and returning to the list
|
|
|
|
*
|
|
|
|
* UI interaction flow tested:
|
|
|
|
* 1. Click on list item
|
|
|
|
* 2. Rotate device
|
|
|
|
* 3. Press back
|
|
|
|
* 4. Result: navigation icon should be a hamburger
|
|
|
|
*/
|
|
|
|
@Test
|
|
|
|
public void restoreHamburgerOnConfigurationChangeOnReturn() {
|
2017-07-17 20:07:11 +02:00
|
|
|
clickAdapterViewItem(0, R.id.list);
|
|
|
|
rotateDevice(getActivity());
|
2017-04-29 17:08:15 +02:00
|
|
|
Espresso.pressBack();
|
|
|
|
|
|
|
|
assertFalse(((T) EspressoTestUtils.getActivity()).getDrawerIndicatorIsArrow());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|