diff --git a/.travis.yml b/.travis.yml index 94c02153f..75f0b4851 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,12 +14,15 @@ android: - extra-android-m2repository - sys-img-armeabi-v7a-android-22 before_script: - - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a -c 100M - - emulator -avd test -no-boot-anim -no-window & + - echo y | android update sdk -a --no-ui --filter android-22 + - echo y | android update sdk -a --no-ui --filter sys-img-armeabi-v7a-android-22 + - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a + - mksdcard -l testSdCard 1024M testSdCardFile.img + - emulator -avd test -no-skin -sdcard testSdCardFile.img -no-window & - android-wait-for-emulator - adb shell input keyevent 82 & script: -- './gradlew build test && ./gradlew testDebug' +- './gradlew build test' # && ./gradlew testDebug' - './gradlew connectedCheck' deploy: - provider: releases diff --git a/enabler/src/androidTest/java/com/openxc/TestUtils.java b/enabler/src/androidTest/java/com/openxc/TestUtils.java index 1fd1d611a..41a670697 100644 --- a/enabler/src/androidTest/java/com/openxc/TestUtils.java +++ b/enabler/src/androidTest/java/com/openxc/TestUtils.java @@ -24,6 +24,8 @@ public static void pause(int millis) { public static URI copyToStorage(Context context, int resource, String filename) { + File openxcDirectory = new File("/sdcard/com.openxc/"); + openxcDirectory.mkdirs(); URI uri = null; try { uri = new URI("file:///sdcard/com.openxc/" + filename); diff --git a/enabler/src/androidTest/java/com/openxc/ui/CanMessageViewFragmentUITests.java b/enabler/src/androidTest/java/com/openxc/ui/CanMessageViewFragmentUITests.java new file mode 100644 index 000000000..2cc3efe2c --- /dev/null +++ b/enabler/src/androidTest/java/com/openxc/ui/CanMessageViewFragmentUITests.java @@ -0,0 +1,46 @@ +package com.openxc.ui; + +import android.test.suitebuilder.annotation.LargeTest; +import android.view.LayoutInflater; +import android.view.View; + +import com.android21buttons.fragmenttestrule.FragmentTestRule; +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.fragment.app.Fragment; +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; +import androidx.test.rule.ActivityTestRule; +import static org.junit.Assert.assertNotNull; + +@LargeTest +@RunWith(AndroidJUnit4ClassRunner.class) +public class CanMessageViewFragmentUITests { + + @Rule + public FragmentTestRule mActivityTestRule = new FragmentTestRule<>(OpenXcEnablerActivity.class,Fragment.class); + + @Test + public void check_for_view_layout_data(){ + View v= LayoutInflater.from(mActivityTestRule.getActivity()).inflate(R.layout.can_message_details,null); + assertNotNull(v); + View vv= LayoutInflater.from(mActivityTestRule.getActivity()).inflate(R.layout.can_message_list_fragment,null); + assertNotNull(vv); + View vvv= LayoutInflater.from(mActivityTestRule.getActivity()).inflate(R.layout.can_message_list_item,null); + assertNotNull(vvv); + } + + @Test + public void check_elements_presence() { + View v= LayoutInflater.from(mActivityTestRule.getActivity()).inflate(R.layout.can_message_details,null); + assertNotNull(v.findViewById(R.id.bus)); + assertNotNull(v.findViewById(R.id.timestamp)); + assertNotNull(v.findViewById(R.id.id)); + assertNotNull(v.findViewById(R.id.data)); + } + +} diff --git a/enabler/src/androidTest/java/com/openxc/ui/SendCanMessageFragmentUITests.java b/enabler/src/androidTest/java/com/openxc/ui/SendCanMessageFragmentUITests.java new file mode 100644 index 000000000..f85ada82e --- /dev/null +++ b/enabler/src/androidTest/java/com/openxc/ui/SendCanMessageFragmentUITests.java @@ -0,0 +1,78 @@ +package com.openxc.ui; + +import android.os.Build; +import android.os.Handler; +import android.os.Looper; +import android.test.suitebuilder.annotation.LargeTest; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.android21buttons.fragmenttestrule.FragmentTestRule; +import com.openxc.enabler.OpenXcEnablerActivity; +import com.openxcplatform.enabler.R; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; + +import androidx.fragment.app.Fragment; +import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; + + +import static org.junit.Assert.assertNotNull; + +@LargeTest +@RunWith(AndroidJUnit4ClassRunner.class) +public class SendCanMessageFragmentUITests { + + @Rule + public FragmentTestRule mActivityTestRule = new FragmentTestRule<>(OpenXcEnablerActivity.class,Fragment.class); + + @Test + public void check_for_view_layout_data(){ + Log.i("Android version", Build.VERSION.RELEASE); + Handler handler = new Handler(Looper.getMainLooper()); + + handler.postDelayed(new Runnable() { + @Override + public void run() { + // Run your task here + if (mActivityTestRule.getActivity() != null) { + View v = LayoutInflater.from(mActivityTestRule.getActivity()).inflate(R.layout.send_can_message_fragment, null); + assertNotNull(v); + } + } + }, 1000 ); + + + } + + @Test + public void check_elements_presence() { + + Handler handler = new Handler(Looper.getMainLooper()); + + handler.postDelayed(new Runnable() { + @Override + public void run() { + if (mActivityTestRule.getActivity() != null) { + View v= LayoutInflater.from(mActivityTestRule.getActivity()).inflate(R.layout.send_can_message_fragment,null); + assertNotNull(v.findViewById(R.id.message_id)); + assertNotNull(v.findViewById(R.id.message_payload)); + assertNotNull(v.findViewById(R.id.message_payload2)); + assertNotNull(v.findViewById(R.id.message_payload3)); + assertNotNull(v.findViewById(R.id.message_payload4)); + assertNotNull(v.findViewById(R.id.message_payload5)); + assertNotNull(v.findViewById(R.id.message_payload6)); + assertNotNull(v.findViewById(R.id.message_payload7)); + assertNotNull(v.findViewById(R.id.message_payload8)); + assertNotNull(v.findViewById(R.id.bus_spinner)); + v.findViewById(R.id.send_request).performClick(); + } + } + }, 1000 ); + } +} diff --git a/enabler/src/androidTest/java/com/openxc/ui/StatusFragmentUITests.java b/enabler/src/androidTest/java/com/openxc/ui/StatusFragmentUITests.java index 1ee7af29f..a10b6647f 100644 --- a/enabler/src/androidTest/java/com/openxc/ui/StatusFragmentUITests.java +++ b/enabler/src/androidTest/java/com/openxc/ui/StatusFragmentUITests.java @@ -1,6 +1,8 @@ package com.openxc.ui; import android.test.suitebuilder.annotation.LargeTest; + +import com.android21buttons.fragmenttestrule.FragmentTestRule; import com.openxc.enabler.OpenXcEnablerActivity; import com.openxcplatform.enabler.R; @@ -8,6 +10,7 @@ import org.junit.Test; import org.junit.runner.RunWith; +import androidx.fragment.app.Fragment; import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner; import androidx.test.rule.ActivityTestRule; @@ -24,7 +27,7 @@ public class StatusFragmentUITests { @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>(OpenXcEnablerActivity.class); + public FragmentTestRule mActivityTestRule = new FragmentTestRule<>(OpenXcEnablerActivity.class,Fragment.class); @Test public void check_elements_presence() { diff --git a/enabler/src/main/AndroidManifest.xml b/enabler/src/main/AndroidManifest.xml index 8cd5a52cb..d86e750fd 100644 --- a/enabler/src/main/AndroidManifest.xml +++ b/enabler/src/main/AndroidManifest.xml @@ -12,6 +12,7 @@ + @@ -24,7 +25,9 @@ android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:requestLegacyExternalStorage="true" android:theme="@android:style/Theme.Holo"> + diff --git a/enabler/src/main/res/layout/send_can_message_fragment.xml b/enabler/src/main/res/layout/send_can_message_fragment.xml index 98a55a321..9fd8c635e 100644 --- a/enabler/src/main/res/layout/send_can_message_fragment.xml +++ b/enabler/src/main/res/layout/send_can_message_fragment.xml @@ -1,7 +1,8 @@ + android:orientation="vertical" + class="com.openxc.enabler.SendCanMessageFragment">