Skip to content

Commit

Permalink
Merge pull request #13 from nus-mtp/development-frontend
Browse files Browse the repository at this point in the history
Development frontend to master for V0.5
  • Loading branch information
Carl26 committed Mar 19, 2017
2 parents 5679847 + 0473544 commit ecf5d59
Show file tree
Hide file tree
Showing 112 changed files with 5,448 additions and 748 deletions.
22 changes: 15 additions & 7 deletions frontend/Movie_Pigeon/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,27 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile files('libs/universal-image-loader-1.9.5.jar')
compile files('libs/gson-2.8.0.jar')
compile files('libs/eventbus-3.0.0.jar')
compile 'com.android.support:appcompat-v7:25.1.1'
compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:recyclerview-v7:25.1.1'
testCompile 'junit:junit:4.12'
compile files('libs/universal-image-loader-1.9.5.jar')
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.okio:okio:1.11.0'
compile 'com.google.code.gson:gson:2.8.0'
compile 'org.greenrobot:eventbus:3.0.0'
compile files('libs/gson-2.8.0.jar')
compile files('libs/eventbus-3.0.0.jar')
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:25.1.1'

// Android runner and rules support
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
// Espresso support
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// intent mocking support
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package org.example.team_pigeon.movie_pigeon;

import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import junit.framework.AssertionFailedError;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

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.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;

/**
* Created by Guo Mingxuan on 19/3/2017.
*/

@RunWith(AndroidJUnit4.class)
@LargeTest
public class ChangeUserInfoActivityTest {

@Rule
public ActivityTestRule<ChangeUserInfoActivity> mActivityRule = new ActivityTestRule<ChangeUserInfoActivity>(ChangeUserInfoActivity.class){
@Override
protected Intent getActivityIntent() {
Context targetContext = InstrumentationRegistry.getInstrumentation()
.getTargetContext();
Intent result = new Intent(targetContext, ThirdPartySignupActivity.class);
result.putExtra("type", "username");
return result;
}
};

@Test
public void loadToolbar() {
try {
onView(withId(R.id.toolbar_user_activity)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadFrameLayout() {
try {
onView(withId(R.id.fl_user_activity)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadUsernameTextView() {
try {
onView(withId(R.id.setting_fragment_username_tv)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadUsernameEdittext() {
try {
onView(withId(R.id.setting_fragment_username_et)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadCurrentPasswordTextView() {
try {
onView(withId(R.id.setting_fragment_now_password_tv)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadCurrentPasswordEdittext() {
try {
onView(withId(R.id.setting_fragment_now_password_et)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadNewPasswordTextView() {
try {
onView(withId(R.id.setting_fragment_password_tv)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadNewPasswordEdittext() {
try {
onView(withId(R.id.setting_fragment_password_et)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadConfirmPasswordTextView() {
try {
onView(withId(R.id.setting_fragment_repeat_password_tv)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadConfirmPasswordEdittext() {
try {
onView(withId(R.id.setting_fragment_repeat_password_et)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadConfirmButton() {
try {
onView(withId(R.id.setting_fragment_confirm)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}

@Test
public void loadCancelButton() {
try {
onView(withId(R.id.setting_fragment_cancel)).check(matches(isDisplayed()));
} catch (AssertionFailedError e) {
e.printStackTrace();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.example.team_pigeon.movie_pigeon;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.example.team_pigeon.movie_pigeon.models.Movie;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.ArrayList;

import static android.support.test.espresso.Espresso.onData;
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.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
* Created by SHENGX on 2017/3/19.
*/
@RunWith(AndroidJUnit4.class)
public class DisplayActivityTest {
@Rule
public ActivityTestRule<DisplayActivity> displayActivityActivityTestRule = new ActivityTestRule<DisplayActivity>(DisplayActivity.class) {
@Override
protected Intent getActivityIntent() {
ArrayList<Movie> testMovieList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
testMovieList.add(new Movie(String.valueOf(i), "id"));
}
Bundle argument = new Bundle();
argument.putSerializable("movieList", testMovieList);
argument.putString("title", "TestBar");
argument.putString("type", "test");
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
Intent result = new Intent(targetContext, DisplayActivity.class);
result.putExtra("bundle",argument);
return result;
}
};

@Test
public void showMovieListProperly() {
onView(withId(R.id.toolbar_display_page)).check(matches(isDisplayed()));
onView(withId(R.id.list_movies)).check(matches(isDisplayed()));
for(int i = 0;i<10;i++) {
onData(withText(String.valueOf(i))).inAdapterView(withId(R.id.list_movies)).atPosition(i);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.example.team_pigeon.movie_pigeon;

import android.content.Context;
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
* Created by SHENGX on 2017/3/19.
*/

@RunWith(AndroidJUnit4.class)
public class HomePageActivityTest {
@Rule
public ActivityTestRule<HomePageActivity> homePageActivityActivityTestRule = new ActivityTestRule<HomePageActivity>(HomePageActivity.class) {
@Override
protected Intent getActivityIntent() {
Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
Intent result = new Intent(targetContext, HomePageActivity.class);
result.putExtra("Token", "test token");
return result;
}
};

@Test
public void ensureUiComponentsDisplayed() {
onView(withId(R.id.rg_tab_bar))
.check(matches(isDisplayed()));
onView(withId(R.id.rb_now_showing))
.check(matches(isDisplayed()));
onView(withId(R.id.rb_home))
.check(matches(isDisplayed()));
onView(withId(R.id.rb_me))
.check(matches(isDisplayed()));
onView(withId(R.id.view_pager))
.check(matches(isDisplayed()));
onView(withId(R.id.rg_tab_bar))
.check(matches(isDisplayed()));
}

@Test
public void viewPagerSwitchCorrectly() {
onView(withText("Cinemas")).perform(click());
onView(withId(R.id.spinner_cinema_brand)).check(matches(isDisplayed()));
onView(withText("Me")).perform(click());
onView(withText("My Ratings")).check(matches(isDisplayed()));
onView(withText("My Bookmarks")).check(matches(isDisplayed()));
onView(withText("Settings")).check(matches(isDisplayed()));
onView(withText("Logout")).check(matches(isDisplayed()));
onView(withText("Home")).perform(click());
onView(withId(R.id.search_view)).check(matches(isDisplayed()));
onView(withId(R.id.grid_now_showing)).check(matches(isDisplayed()));
onView(withId(R.id.grid_recommended)).check(matches(isDisplayed()));
}
}
Loading

0 comments on commit ecf5d59

Please sign in to comment.