1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-22 00:42:16 -05:00

Test scenarios including connecting to a server

This commit is contained in:
Sebastian Kaspari 2010-11-07 13:32:00 +01:00
parent 514aaf5cf1
commit 37f12b6ab7
2 changed files with 114 additions and 1 deletions

View File

@ -0,0 +1,98 @@
/*
Yaaic - Yet Another Android IRC Client
Copyright 2009-2010 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
package org.yaaic.test.scenario;
import android.test.ActivityInstrumentationTestCase2;
import com.jayway.android.robotium.solo.Solo;
/**
* Test scenarios including connecting to a server
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
@SuppressWarnings("rawtypes")
public class ConnectionScenarios extends ActivityInstrumentationTestCase2
{
private ScenarioHelper helper;
private Solo solo;
/**
* Create a new ConnectionScenario instance
*
* @throws ClassNotFoundException
*/
@SuppressWarnings("unchecked")
public ConnectionScenarios() throws ClassNotFoundException
{
super(
"org.yaaic",
Class.forName("org.yaaic.activity.ServersActivity")
);
}
/**
* Setup test case
*/
@Override
protected void setUp()
{
solo = new Solo(getInstrumentation(), getActivity());
helper = new ScenarioHelper(solo);
helper.createTestServer();
helper.connectToServer();
}
/**
* Cleanup after test
*/
@Override
protected void tearDown()
{
helper.disconnectFromServer();
helper.deleteTestServer();
solo.sleep(500);
}
/**
* Scenario: Join a channel
*
* - Connect to server
* - Enter command: /j #yaaic-test
* - A new conversation with text #yaaic-test appears
* - Disconnect
*/
public void testJoiningChannel()
{
// Join channel
solo.enterText(0, "/j #yaaic-test");
solo.sendKey(Solo.ENTER);
solo.sleep(1000);
// Assert channel joined
assertTrue(solo.searchText("#yaaic-test"));
}
}

View File

@ -20,6 +20,8 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
package org.yaaic.test.scenario;
import com.jayway.android.robotium.solo.Solo;
import android.test.ActivityInstrumentationTestCase2;
@ -32,7 +34,13 @@ import android.test.ActivityInstrumentationTestCase2;
public class ServerListScenarios extends ActivityInstrumentationTestCase2
{
private Solo solo;
private ScenarioHelper helper;
/**
* Create a new ServerListScenarios instance
*
* @throws ClassNotFoundException
*/
@SuppressWarnings("unchecked")
public ServerListScenarios() throws ClassNotFoundException
{
@ -42,9 +50,13 @@ public class ServerListScenarios extends ActivityInstrumentationTestCase2
);
}
/**
* Setup test case
*/
protected void setUp()
{
solo = new Solo(getInstrumentation(), getActivity());
solo = new Solo(getInstrumentation(), getActivity());
helper = new ScenarioHelper(solo);
}
/**
@ -63,6 +75,9 @@ public class ServerListScenarios extends ActivityInstrumentationTestCase2
*/
public void testAddingAndRemovingServer()
{
// Delete Testserver if already exists
helper.deleteTestServer();
int numberOfServersBefore = solo.getCurrentListViews().get(0).getCount();
// Add server