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 for datasources and recording #388

Open
wants to merge 6 commits 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,80 @@
package com.openxc.ui;

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

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 junit.framework.TestCase.assertFalse;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;

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

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

@Test
public void check_for_datasources_preference(){
Handler handler = new Handler(Looper.getMainLooper());

handler.postDelayed(new Runnable() {
@Override
public void run() {
if (mActivityTestRule.getActivity() != null) {
assertNotNull(onView(withId(R.xml.data_source_preferences)));
assertTrue(isShown(R.string.vehicle_interface_key));
assertTrue(isShown(R.string.data_format_key));
assertTrue(isShown(R.string.native_gps_checkbox_key));
assertTrue(isShown(R.string.bluetooth_polling_key));
assertFalse(isShown(R.string.network_host_key));
assertFalse(isShown(R.string.network_port_key));
assertFalse(isShown(R.string.trace_source_file_key));
assertTrue(isShown(R.string.trace_source_playing_checkbox_key));
assertTrue(isShown(R.string.phone_source_polling_checkbox_key));
}
}
}, 1000 );

}

@Test
public void check_for_recording_preference(){
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)));
assertTrue(isShown(R.string.recording_directory_key));
assertTrue(isShown(R.string.uploading_checkbox_key));
assertTrue(isShown(R.string.uploading_path_key));
assertTrue(isShown(R.string.uploading_source_name_key));
assertTrue(isShown(R.string.dweeting_checkbox_key));
assertTrue(isShown(R.string.dweeting_thingname_key));
}
}
}, 1000 );

}

public boolean isShown(int id){
return PreferenceManager.getDefaultSharedPreferences(mActivityTestRule.getActivity().getApplicationContext()).contains(
mActivityTestRule.getActivity().getString(id));
}

}