<commit_before>package com.example.moodly;

import android.app.Activity;
import android.support.design.widget.FloatingActionButton;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.Spinner;

import com.example.moodly.Activities.LoginScreen;
import com.example.moodly.Activities.ViewMood;
import com.example.moodly.Activities.ViewMoodList;
import com.robotium.solo.Solo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

/**
 * Created by tuongmin on 3/16/17.
 */

public class MoodIntentTest extends ActivityInstrumentationTestCase2<LoginScreen> {
    private Solo solo;

    public MoodIntentTest() {
        super(com.example.moodly.Activities.LoginScreen.class);
    }

    public void setUp() throws Exception{
        solo = new Solo(getInstrumentation(), getActivity());
    }

    public void testStart() throws Exception {
        Activity activity = getActivity();
    }

    public void actionLogin() {
        solo.assertCurrentActivity("Wrong Activity", LoginScreen.class);

        solo.enterText((EditText) solo.getView(R.id.userName), "Minh");

        solo.clickOnButton("Login");

        solo.assertCurrentActivity("Wrong Activities", ViewMoodList.class);
    }

    public void actionLogOut() {
        solo.sendKey(solo.MENU);

        solo.clickOnText("Log Out");

        solo.assertCurrentActivity("Wrong Activity", LoginScreen.class);
    }

    protected String getRDString() {
        String CHARS = "abcdefghijklmnopqrstuvwxyz1234567890";
        StringBuilder stringBuilder = new StringBuilder();
        Random rnd = new Random();
        while (stringBuilder.length() < 18) {
            int index = (int) (rnd.nextFloat() * CHARS.length());
            stringBuilder.append(CHARS.charAt(index));
        }
        String Str = stringBuilder.toString();
        return Str;

    }

    public void test1_AddMood() {
        actionLogin();

        solo.clickOnView((FloatingActionButton) solo.getView(R.id.fab));
        solo.assertCurrentActivity("Wrong Activities", ViewMood.class);
        Spinner emoij = (Spinner) solo.getView(R.id.spinner_emotion);
        solo.clickOnView(emoij);
        solo.clickOnText("Anger");

        solo.clickOnView((EditText) solo.getView(R.id.view_date));
        solo.clickOnText("OK");
        solo.clickOnText("OK");

        solo.enterText((EditText) solo.getView(R.id.view_reason), "test reason");

        solo.clickOnText("Save Mood");

        solo.assertCurrentActivity("Wrong Activity", ViewMoodList.class);

        assertEquals(solo.searchText("Anger"), true);

        actionLogOut();
    }

    public void t2_FilterByMood () {
        actionLogin();
        solo.clickOnView((FloatingActionButton) solo.getView(R.id.filterButton));

        solo.clickOnText("Sad");

        solo.clickOnText("OK");

        solo.clickOnText("No");

        solo.clickOnText("Yes");

        ArrayList<String> moods = new ArrayList<>(Arrays.asList("Anger","Confusion","Disgust","Fear","Shame","Surprise"));
        for (String mood: moods) {<commit_msg>Test filter by emoij. Need to pull Melvin's refresh filter first.<commit_after>package com.example.moodly;

import android.app.Activity;
import android.support.design.widget.FloatingActionButton;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.Spinner;

import com.example.moodly.Activities.LoginScreen;
import com.example.moodly.Activities.ViewMood;
import com.example.moodly.Activities.ViewMoodList;
import com.robotium.solo.Solo;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

/**
 * Created by tuongmin on 3/16/17.
 */

public class MoodIntentTest extends ActivityInstrumentationTestCase2<LoginScreen> {
    private Solo solo;

    public MoodIntentTest() {
        super(com.example.moodly.Activities.LoginScreen.class);
    }

    public void setUp() throws Exception{
        solo = new Solo(getInstrumentation(), getActivity());
    }

    public void testStart() throws Exception {
        Activity activity = getActivity();
    }

    public void actionLogin() {
        solo.assertCurrentActivity("Wrong Activity", LoginScreen.class);

        solo.enterText((EditText) solo.getView(R.id.userName), "Minh");

        solo.clickOnButton("Login");

        solo.assertCurrentActivity("Wrong Activities", ViewMoodList.class);
    }

    public void actionLogOut() {
        solo.sendKey(solo.MENU);

        solo.clickOnText("Log Out");

        solo.assertCurrentActivity("Wrong Activity", LoginScreen.class);
    }

    protected String getRDString() {
        String CHARS = "abcdefghijklmnopqrstuvwxyz1234567890";
        StringBuilder stringBuilder = new StringBuilder();
        Random rnd = new Random();
        while (stringBuilder.length() < 18) {
            int index = (int) (rnd.nextFloat() * CHARS.length());
            stringBuilder.append(CHARS.charAt(index));
        }
        String Str = stringBuilder.toString();
        return Str;

    }

    public void test1_AddMood() {
        actionLogin();

        solo.clickOnView((FloatingActionButton) solo.getView(R.id.fab));
        solo.assertCurrentActivity("Wrong Activities", ViewMood.class);
        Spinner emoij = (Spinner) solo.getView(R.id.spinner_emotion);
        solo.clickOnView(emoij);
        solo.clickOnText("Anger");

        solo.clickOnView((EditText) solo.getView(R.id.view_date));
        solo.clickOnText("OK");
        solo.clickOnText("OK");

        solo.enterText((EditText) solo.getView(R.id.view_reason), "test reason");

        solo.clickOnText("Save Mood");

        solo.assertCurrentActivity("Wrong Activity", ViewMoodList.class);

        assertEquals(solo.searchText("Anger"), true);

        actionLogOut();
    }

    public void test2_FilterByMood () {
        actionLogin();
        solo.clickOnView((FloatingActionButton) solo.getView(R.id.filterButton));

        solo.clickOnText("Sad");

        solo.clickOnText("OK");

        solo.clickOnText("No");

        solo.clickOnText("Yes");

        ArrayList<String> moods = new ArrayList<>(Arrays.asList("Anger","Confusion","Disgust","Fear","Shame","Surprise"));
        for (String mood: moods) {
{'fraction_non_alphanumeric': 0.12501960784313726, 'fraction_numerical': 0.006588235294117647, 'mean_word_length': 3.328581126951799, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6719551', 'n_tokens_mistral': 1973, 'n_tokens_neox': 1921, 'n_words': 334}