Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unit test for settings notification output about pages #391

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.openxc.ui;

import android.os.Handler;
import android.os.Looper;
import android.preference.PreferenceManager;
import android.test.suitebuilder.annotation.LargeTest;
import android.view.LayoutInflater;
import android.view.View;

import com.openxc.enabler.OpenXcEnablerActivity;
import com.openxcplatform.enabler.R;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
import androidx.test.rule.ActivityTestRule;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static junit.framework.TestCase.assertNotNull;

@LargeTest
@RunWith(AndroidJUnit4ClassRunner.class)
public class SettingsPagesUITests {

@Rule
public ActivityTestRule<OpenXcEnablerActivity> mActivityTestRule = new ActivityTestRule<>(OpenXcEnablerActivity.class);

@Test
public void check_for_SettingsPage_preferences(){
Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (mActivityTestRule.getActivity() != null) {
assertNotNull(onView(withId(R.xml.recording_preferences)));
assertNotNull(onView(withId(R.xml.data_source_preferences)));
assertNotNull(onView(withId(R.xml.output_preferences)));
assertNotNull(onView(withId(R.xml.about_preferences)));
assertNotNull(onView(withId(R.xml.notification_preferences)));
}
}
}, 1000 );

}

@Test
public void check_elements_presence() {
assertNotNull(onView(withText("Overwrite Native GPS")));
assertNotNull(onView(withText("Power Drop")));
assertNotNull(onView(withText("Network Drop")));
assertNotNull(onView(withText("USB Drop")));
assertNotNull(onView(withText("About OpenXC")));
assertNotNull(onView(withText("Version")));
assertNotNull(onView(withText("7.1.0")));
assertNotNull(onView(withText("Tap here to view license info")));
}
}