forked from Mirroring/Kore
Implemented testing actionbar state (#382)
* Added JSON datafiles for TV shows and music videos * Implemented instrumentations tests for MoviesActivity, MusicActivity, TVShowActivity, and AddonsActivity. * Moved RestoreSearchQueryViewPagerTest to music package as it uses the MusicActivity * Moved RestoreSearchQueryListFragmentTest to movies packages as it uses the MoviesActivity * Added scripts to get JSON data for music videos, addons, and TV shows * Added sequence diagram for BaseMediaActivity to clarify new setup * Refactored BaseMediaActivity to comply with diagram * Refactored SyncMusicVideos and SyncTVShows so we can use the same code for adding test data as we use for adding real data. * Removed unused StringBuffer and synchronize block in MockTcpServermaster
parent
46bb4a4bfc
commit
1cb77876be
@ -0,0 +1,106 @@
|
||||
/*
|
||||
* 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.content.Intent;
|
||||
import android.support.test.espresso.Espresso;
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.xbmc.kore.host.HostInfo;
|
||||
import org.xbmc.kore.jsonrpc.HostConnection;
|
||||
import org.xbmc.kore.testhelpers.LoaderIdlingResource;
|
||||
import org.xbmc.kore.testhelpers.Utils;
|
||||
import org.xbmc.kore.testutils.Database;
|
||||
import org.xbmc.kore.testutils.tcpserver.MockTcpServer;
|
||||
import org.xbmc.kore.testutils.tcpserver.handlers.AddonsHandler;
|
||||
import org.xbmc.kore.testutils.tcpserver.handlers.JSONConnectionHandlerManager;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@Ignore
|
||||
abstract public class AbstractTestClass<T extends AppCompatActivity> {
|
||||
|
||||
abstract protected ActivityTestRule<T> getActivityTestRule();
|
||||
|
||||
private LoaderIdlingResource loaderIdlingResource;
|
||||
private ActivityTestRule<T> activityTestRule;
|
||||
private static MockTcpServer server;
|
||||
private static JSONConnectionHandlerManager manager;
|
||||
private AddonsHandler addonsHandler;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupMockTCPServer() throws Throwable {
|
||||
manager = new JSONConnectionHandlerManager();
|
||||
server = new MockTcpServer(manager);
|
||||
server.start();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Throwable {
|
||||
|
||||
activityTestRule = getActivityTestRule();
|
||||
|
||||
//Note: as the activity is not yet available in @BeforeClass we need
|
||||
// to add the handler here
|
||||
if (addonsHandler == null) {
|
||||
addonsHandler = new AddonsHandler(activityTestRule.getActivity());
|
||||
manager.addHandler(addonsHandler);
|
||||
}
|
||||
|
||||
HostInfo hostInfo = Database.addHost(activityTestRule.getActivity(), server.getHostName(),
|
||||
HostConnection.PROTOCOL_TCP, HostInfo.DEFAULT_HTTP_PORT,
|
||||
server.getPort());
|
||||
|
||||
Utils.initialize(activityTestRule, hostInfo);
|
||||
|
||||
loaderIdlingResource = new LoaderIdlingResource(activityTestRule.getActivity().getSupportLoaderManager());
|
||||
Espresso.registerIdlingResources(loaderIdlingResource);
|
||||
|
||||
activityTestRule.launchActivity(new Intent());
|
||||
|
||||
Utils.closeDrawer(activityTestRule);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if ( loaderIdlingResource != null )
|
||||
Espresso.unregisterIdlingResources(loaderIdlingResource);
|
||||
|
||||
Utils.cleanup();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanup() throws IOException {
|
||||
server.shutdown();
|
||||
}
|
||||
|
||||
protected T getActivity() {
|
||||
if (activityTestRule != null) {
|
||||
return activityTestRule.getActivity();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* 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 android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.xbmc.kore.R;
|
||||
import org.xbmc.kore.testhelpers.EspressoTestUtils;
|
||||
import org.xbmc.kore.ui.BaseMediaActivity;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
|
||||
|
||||
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() {
|
||||
EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
|
||||
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() {
|
||||
EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
|
||||
EspressoTestUtils.rotateDevice(getActivity());
|
||||
|
||||
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() {
|
||||
EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
|
||||
EspressoTestUtils.rotateDevice(getActivity());
|
||||
Espresso.pressBack();
|
||||
|
||||
assertFalse(((T) EspressoTestUtils.getActivity()).getDrawerIndicatorIsArrow());
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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.addons;
|
||||
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.xbmc.kore.R;
|
||||
import org.xbmc.kore.testhelpers.EspressoTestUtils;
|
||||
import org.xbmc.kore.testhelpers.Utils;
|
||||
import org.xbmc.kore.tests.ui.AbstractTestClass;
|
||||
import org.xbmc.kore.tests.ui.BaseMediaActivityTests;
|
||||
import org.xbmc.kore.ui.sections.video.MoviesActivity;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.xbmc.kore.testhelpers.EspressoTestUtils.selectListItemPressBackAndCheckActionbarTitle;
|
||||
|
||||
/**
|
||||
* Note: we use MoviesActivity here instead of AddonsActivity. The reason is that we use @Rule
|
||||
* to start the activity which is done prior to executing @Before. This results in a deadlock
|
||||
* situation.
|
||||
*
|
||||
* Normal startup procedure would be as follows:
|
||||
*
|
||||
* 1. Start MockTCPServer {@link AbstractTestClass#setupMockTCPServer()}
|
||||
* 2. Start activity {mActivityRule}
|
||||
* 3. Espresso waits for activity to become idle before calling {@link AbstractTestClass#setUp()}
|
||||
* 4. Add AddonsHandler {@link AbstractTestClass#setUp()}
|
||||
*
|
||||
* At step 2 the AddonsActivity displays an animated progress indicator while it waits for the
|
||||
* MockTCPServer to send the list of addons.
|
||||
* This is never send as the {@link org.xbmc.kore.testutils.tcpserver.handlers.AddonsHandler} is
|
||||
* added in {@link super#setUp()} which is never started by Espresso as it waits for
|
||||
* {@link org.xbmc.kore.ui.sections.addon.AddonsActivity} to become idle.
|
||||
*/
|
||||
public class AddonsActivityTests extends BaseMediaActivityTests<MoviesActivity> {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<MoviesActivity> mActivityRule = new ActivityTestRule<>(
|
||||
MoviesActivity.class);
|
||||
|
||||
@Override
|
||||
protected ActivityTestRule<MoviesActivity> getActivityTestRule() {
|
||||
return mActivityRule;
|
||||
}
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Throwable {
|
||||
super.setUp();
|
||||
//Start the AddonsActivity from the MoviesActivity
|
||||
Utils.openDrawer(getActivityTestRule());
|
||||
EspressoTestUtils.clickAdapterViewItem(7, R.id.navigation_drawer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title initially displays Addons
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleMain() {
|
||||
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
|
||||
.check(matches(withText(R.string.addons)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting a list item
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitle() {
|
||||
EspressoTestUtils.selectListItemAndCheckActionbarTitle(0, R.id.list,
|
||||
"Dumpert");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after a configuration change
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Rotate device
|
||||
* 3. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnConfigurationStateChanged() {
|
||||
EspressoTestUtils.selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list,
|
||||
"Dumpert",
|
||||
getActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after returning from a movie selection
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Press back
|
||||
* 3. Result: action bar title should show main title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnReturningFromMovie() {
|
||||
selectListItemPressBackAndCheckActionbarTitle(0, R.id.list,
|
||||
getActivity().getString(R.string.addons));
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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.movies;
|
||||
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.xbmc.kore.R;
|
||||
import org.xbmc.kore.testhelpers.EspressoTestUtils;
|
||||
import org.xbmc.kore.tests.ui.BaseMediaActivityTests;
|
||||
import org.xbmc.kore.ui.sections.video.MoviesActivity;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.xbmc.kore.testhelpers.EspressoTestUtils.selectListItemPressBackAndCheckActionbarTitle;
|
||||
|
||||
public class MoviesActivityTests extends BaseMediaActivityTests<MoviesActivity> {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<MoviesActivity> mActivityRule = new ActivityTestRule<>(
|
||||
MoviesActivity.class);
|
||||
|
||||
@Override
|
||||
protected ActivityTestRule<MoviesActivity> getActivityTestRule() {
|
||||
return mActivityRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title initially displays Movies
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleMain() {
|
||||
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
|
||||
.check(matches(withText(R.string.movies)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting a list item
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitle() {
|
||||
EspressoTestUtils.selectListItemAndCheckActionbarTitle(0, R.id.list,
|
||||
"#Rookie93 Marc Marquez: Beyond the Smile");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after a configuration change
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Rotate device
|
||||
* 3. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnConfigurationStateChanged() {
|
||||
EspressoTestUtils.selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list,
|
||||
"#Rookie93 Marc Marquez: Beyond the Smile",
|
||||
mActivityRule.getActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after returning from a movie selection
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Press back
|
||||
* 3. Result: action bar title should show main title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnReturningFromMovie() {
|
||||
selectListItemPressBackAndCheckActionbarTitle(0, R.id.list,
|
||||
mActivityRule.getActivity().getString(R.string.movies));
|
||||
}
|
||||
}
|
@ -0,0 +1,260 @@
|
||||
/*
|
||||
* 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.music;
|
||||
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.xbmc.kore.R;
|
||||
import org.xbmc.kore.testhelpers.EspressoTestUtils;
|
||||
import org.xbmc.kore.tests.ui.BaseMediaActivityTests;
|
||||
import org.xbmc.kore.ui.sections.audio.MusicActivity;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.xbmc.kore.testhelpers.EspressoTestUtils.clickAlbumsTab;
|
||||
import static org.xbmc.kore.testhelpers.EspressoTestUtils.clickGenresTab;
|
||||
import static org.xbmc.kore.testhelpers.EspressoTestUtils.clickMusicVideosTab;
|
||||
import static org.xbmc.kore.testhelpers.EspressoTestUtils.selectListItemAndCheckActionbarTitle;
|
||||
import static org.xbmc.kore.testhelpers.EspressoTestUtils.selectListItemPressBackAndCheckActionbarTitle;
|
||||
import static org.xbmc.kore.testhelpers.EspressoTestUtils.selectListItemRotateDeviceAndCheckActionbarTitle;
|
||||
|
||||
public class MusicActivityTests extends BaseMediaActivityTests<MusicActivity> {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<MusicActivity> musicActivityActivityTestRule =
|
||||
new ActivityTestRule<>(MusicActivity.class);
|
||||
|
||||
@Override
|
||||
protected ActivityTestRule<MusicActivity> getActivityTestRule() {
|
||||
return musicActivityActivityTestRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title initially displays Music
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleMain() {
|
||||
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
|
||||
.check(matches(withText(R.string.music)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting an artist
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleArtist() {
|
||||
selectListItemAndCheckActionbarTitle(0, R.id.list, "ABC Orch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting an album
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on albums tab
|
||||
* 2. Click on list item
|
||||
* 3. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleAlbum() {
|
||||
clickAlbumsTab();
|
||||
selectListItemAndCheckActionbarTitle(0, R.id.list, "1958 - The Fabulous Johnny Cash");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting a genre
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on genres tab
|
||||
* 2. Click on list item
|
||||
* 3. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleGenre() {
|
||||
clickGenresTab();
|
||||
selectListItemAndCheckActionbarTitle(0, R.id.list, "Ambient");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting a video
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on videos tab
|
||||
* 2. Click on list item
|
||||
* 3. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleVideo() {
|
||||
clickMusicVideosTab();
|
||||
selectListItemAndCheckActionbarTitle(0, R.id.list, "(You Drive Me) Crazy");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after a configuration change when artist
|
||||
* is selected
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Rotate device
|
||||
* 3. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleArtistOnConfigurationStateChanged() {
|
||||
selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list,
|
||||
"ABC Orch", getActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after a configuration change when album
|
||||
* is selected
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Select albums tab
|
||||
* 2. Click on list item
|
||||
* 3. Rotate device
|
||||
* 4. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleAlbumOnConfigurationStateChanged() {
|
||||
clickAlbumsTab();
|
||||
selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list,
|
||||
"1958 - The Fabulous Johnny Cash",
|
||||
getActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after a configuration change when genre
|
||||
* is selected
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Select genres tab
|
||||
* 2. Click on list item
|
||||
* 3. Rotate device
|
||||
* 4. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleGenreOnConfigurationStateChanged() {
|
||||
clickGenresTab();
|
||||
selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list,
|
||||
"Ambient", getActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after a configuration change when music video
|
||||
* is selected
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Select music videos tab
|
||||
* 2. Click on list item
|
||||
* 3. Rotate device
|
||||
* 4. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleMusicVideoOnConfigurationStateChanged() {
|
||||
clickMusicVideosTab();
|
||||
selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list,
|
||||
"(You Drive Me) Crazy",
|
||||
getActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after returning from artist selection
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Press back
|
||||
* 3. Result: action bar title should show main title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnReturningFromArtist() {
|
||||
selectListItemPressBackAndCheckActionbarTitle(0, R.id.list,
|
||||
getActivity().getString(R.string.music));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after returning from an album under
|
||||
* artist
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Select albums tab
|
||||
* 3. Press back
|
||||
* 4. Result: action bar title should show artist title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnArtistOnReturningFromAlbum() {
|
||||
EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
|
||||
clickAlbumsTab();
|
||||
selectListItemPressBackAndCheckActionbarTitle(0, R.id.list, "ABC Orch");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after returning from music video selection
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Press back
|
||||
* 3. Result: action bar title should show main title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnReturningFromMusicVideo() {
|
||||
clickMusicVideosTab();
|
||||
selectListItemPressBackAndCheckActionbarTitle(0, R.id.list,
|
||||
getActivity().getString(R.string.music));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after returning from genre selection
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Press back
|
||||
* 3. Result: action bar title should show main title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnReturningFromGenre() {
|
||||
clickGenresTab();
|
||||
selectListItemPressBackAndCheckActionbarTitle(0, R.id.list,
|
||||
getActivity().getString(R.string.music));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after returning from album selection
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Press back
|
||||
* 3. Result: action bar title should show main title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnReturningFromAlbum() {
|
||||
clickAlbumsTab();
|
||||
selectListItemPressBackAndCheckActionbarTitle(0, R.id.list,
|
||||
getActivity().getString(R.string.music));
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* 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.tvshows;
|
||||
|
||||
import android.support.test.rule.ActivityTestRule;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.xbmc.kore.R;
|
||||
import org.xbmc.kore.testhelpers.EspressoTestUtils;
|
||||
import org.xbmc.kore.tests.ui.BaseMediaActivityTests;
|
||||
import org.xbmc.kore.ui.sections.video.TVShowsActivity;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.action.ViewActions.click;
|
||||
import static android.support.test.espresso.action.ViewActions.scrollTo;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withParent;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
||||
public class TVShowsActivityTests extends BaseMediaActivityTests<TVShowsActivity> {
|
||||
|
||||
@Rule
|
||||
public ActivityTestRule<TVShowsActivity> mActivityRule = new ActivityTestRule<>(
|
||||
TVShowsActivity.class);
|
||||
|
||||
@Override
|
||||
protected ActivityTestRule<TVShowsActivity> getActivityTestRule() {
|
||||
return mActivityRule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title initially displays TV Shows
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleMain() {
|
||||
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
|
||||
.check(matches(withText(R.string.tv_shows)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting a list item
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on list item
|
||||
* 2. Result: action bar title should show list item title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitle() {
|
||||
EspressoTestUtils.selectListItemAndCheckActionbarTitle(0, R.id.list, "11.22.63");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting a season
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on TV Show item
|
||||
* 2. Click on next episode item
|
||||
* 3. Result: action bar title should show next episode title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleOnNextEpisode() {
|
||||
EspressoTestUtils.clickAdapterViewItem(1, R.id.list);
|
||||
onView( withId(R.id.next_episode_list)).perform( scrollTo(), click());
|
||||
|
||||
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
|
||||
.check(matches(withText("3")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting a season
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on TV Show item
|
||||
* 2. Click on season item
|
||||
* 3. Result: action bar title should show season title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleOnSeasonList() {
|
||||
EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
|
||||
onView( withId(R.id.seasons_list)).perform( scrollTo(), click());
|
||||
|
||||
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
|
||||
.check(matches(withText("Season 01")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly set after selecting an episode from the season list
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on TV Show item
|
||||
* 2. Click on season item
|
||||
* 3. Click on an episode
|
||||
* 4. Result: action bar title should show episode title
|
||||
*/
|
||||
@Test
|
||||
public void setActionBarTitleOnSeasonListEpisode() {
|
||||
EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
|
||||
onView( withId(R.id.seasons_list)).perform( scrollTo(), click());
|
||||
EspressoTestUtils.selectListItemAndCheckActionbarTitle(0, R.id.list, "11.22.63");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored after a configuration change
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on TV Show item
|
||||
* 2. Rotate device
|
||||
* 3. Result: action bar title should show TV show item title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleOnConfigurationStateChanged() {
|
||||
EspressoTestUtils.selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list,
|
||||
"11.22.63",
|
||||
mActivityRule.getActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored on season list after a configuration change
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on TV Show item
|
||||
* 2. Click on season item
|
||||
* 3. Rotate device
|
||||
* 4. Result: action bar title should show season title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleSeasonListOnConfigurationStateChanged() {
|
||||
EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
|
||||
onView( withId(R.id.seasons_list)).perform( scrollTo(), click());
|
||||
EspressoTestUtils.rotateDevice(mActivityRule.getActivity());
|
||||
|
||||
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
|
||||
.check(matches(withText("Season 01")));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored on episode item title after a configuration change
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on TV Show item
|
||||
* 2. Click on season item
|
||||
* 3. Click on episode item
|
||||
* 4. Rotate device
|
||||
* 5. Result: action bar title should TV show title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleSeasonListEpisodeOnConfigurationStateChanged() {
|
||||
EspressoTestUtils.clickAdapterViewItem(0, R.id.list);
|
||||
onView( withId(R.id.seasons_list)).perform( scrollTo(), click());
|
||||
EspressoTestUtils.selectListItemRotateDeviceAndCheckActionbarTitle(0, R.id.list,
|
||||
"11.22.63",
|
||||
mActivityRule.getActivity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if action bar title is correctly restored on next episode item title after a configuration change
|
||||
*
|
||||
* UI interaction flow tested:
|
||||
* 1. Click on TV Show item
|
||||
* 2. Click on next episode item
|
||||
* 3. Rotate device
|
||||
* 4. Result: action bar title should show season title
|
||||
*/
|
||||
@Test
|
||||
public void restoreActionBarTitleNextEpisodeOnConfigurationStateChanged() {
|
||||
EspressoTestUtils.clickAdapterViewItem(1, R.id.list);
|
||||
onView( withId(R.id.next_episode_list)).perform( scrollTo() );
|
||||
onView( withText("You'll See the Sparkle")).perform( click() );
|
||||
EspressoTestUtils.rotateDevice(mActivityRule.getActivity());
|
||||
|
||||
onView(allOf(instanceOf(TextView.class), withParent(withId(R.id.default_toolbar))))
|
||||
.check(matches(withText("3")));
|
||||
}
|
||||
}
|