From acb57683297428c0a5cee8c5d6d3a98e5d5788d3 Mon Sep 17 00:00:00 2001 From: robert-groebl Date: Wed, 11 Jun 2014 13:56:04 +0200 Subject: [PATCH] [RG, MK]{tests} T - UI tests, should not fail. --- NAM/AndroidManifest.xml | 3 +- NAM_tests/AndroidManifest.xml | 4 +- .../src/com/sw/nam/test/AddContactTest.java | 2 +- NAM_tests/src/com/sw/nam/test/ChatTest.java | 41 ++++++++++--------- NAM_tests/src/com/sw/nam/test/LoginTest.java | 8 +--- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/NAM/AndroidManifest.xml b/NAM/AndroidManifest.xml index 9f56745..8ca0d9f 100644 --- a/NAM/AndroidManifest.xml +++ b/NAM/AndroidManifest.xml @@ -5,7 +5,7 @@ android:versionName="1.0" > + - + + diff --git a/NAM_tests/src/com/sw/nam/test/AddContactTest.java b/NAM_tests/src/com/sw/nam/test/AddContactTest.java index 4451cb9..0c3fd62 100644 --- a/NAM_tests/src/com/sw/nam/test/AddContactTest.java +++ b/NAM_tests/src/com/sw/nam/test/AddContactTest.java @@ -19,7 +19,7 @@ protected void setUp() throws Exception { } protected void tearDown() throws Exception { - super.tearDown(); + solo.finishOpenedActivities(); } public void test1InvalidEmail() { diff --git a/NAM_tests/src/com/sw/nam/test/ChatTest.java b/NAM_tests/src/com/sw/nam/test/ChatTest.java index f31bb9c..506246b 100644 --- a/NAM_tests/src/com/sw/nam/test/ChatTest.java +++ b/NAM_tests/src/com/sw/nam/test/ChatTest.java @@ -4,7 +4,6 @@ import android.accounts.Account; import android.accounts.AccountManager; import android.test.ActivityInstrumentationTestCase2; - import com.robotium.solo.Solo; import com.sw.nam.ChatActivity; import com.sw.nam.MainActivity; @@ -22,26 +21,28 @@ protected void setUp() throws Exception { } protected void tearDown() throws Exception { - super.tearDown(); + solo.finishOpenedActivities(); } - public void test1EnterChat() { -// Account[] accounts = AccountManager.get(getInstrumentation().getContext()) -// .getAccountsByType("com.google"); -// String email = accounts[0].name; -// solo.clickOnView(getActivity().findViewById(com.sw.nam.R.id.action_add)); -// solo.enterText(0, email);; -// solo.clickOnButton(1); -// assertTrue("Could not add contact!", solo.waitForText("email")); -// solo.clickOnText(email); -//// assertTrue("Could not enter chat!", solo.waitForActivity(ChatActivity.class)); -// solo.clickLongOnTextAndPress(email, 1); + public void testChat() { + Account[] accounts = AccountManager.get(getInstrumentation().getContext()) + .getAccountsByType("com.google"); + String email = accounts[0].name; + String message = "Test message!"; + + solo.clickOnView(getActivity().findViewById(com.sw.nam.R.id.action_add)); + solo.enterText(0, email); + solo.clickOnButton(1); + assertTrue("Could not add contact!", solo.waitForText(email + " added!")); + solo.clickInList(0); + assertTrue("Could not enter chat!", solo.waitForActivity(ChatActivity.class)); + solo.enterText(0, message); + solo.clickOnButton("Send"); + assertTrue("Could not send message!", solo.waitForText(message)); + assertTrue("Could not reveice message!", solo.waitForText(message, 2, 1000)); + solo.clickOnActionBarHomeButton(); + assertTrue("Could not leave chat!", solo.waitForActivity(MainActivity.class)); + solo.clickLongOnTextAndPress(email, 1); + assertTrue("Could not delete contact!", solo.waitForText("Contact deleted")); } - - -// public void test5ContactDelete() { -// String name = "Bot"; -// solo.clickLongOnTextAndPress(name, 1); -// assertFalse("User not deleted!", solo.searchText(name)); -// } } \ No newline at end of file diff --git a/NAM_tests/src/com/sw/nam/test/LoginTest.java b/NAM_tests/src/com/sw/nam/test/LoginTest.java index 597d6a7..7e3469d 100644 --- a/NAM_tests/src/com/sw/nam/test/LoginTest.java +++ b/NAM_tests/src/com/sw/nam/test/LoginTest.java @@ -1,7 +1,5 @@ package com.sw.nam.test; -import android.accounts.Account; -import android.accounts.AccountManager; import android.test.ActivityInstrumentationTestCase2; import com.robotium.solo.Solo; import com.sw.nam.MainActivity; @@ -19,12 +17,10 @@ protected void setUp() throws Exception { } protected void tearDown() throws Exception { - super.tearDown(); + han.finishOpenedActivities(); } public void test1LoggedIn() { - Account[] accounts = AccountManager.get(getInstrumentation().getContext()) - .getAccountsByType("com.google"); - assertTrue("not logged in", han.searchText(accounts[0].name)); + assertTrue("not logged in", han.searchText("Online")); } }