-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from openxc/update-test-unit-library
Migrate openxc-android project to Androidx which supports the the tes…
- Loading branch information
Showing
21 changed files
with
795 additions
and
798 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 50 additions & 50 deletions
100
enabler/src/androidTest/java/com/openxc/SupportSettingsUtilsTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
//package com.openxc; | ||
// | ||
//import java.util.HashSet; | ||
//import java.util.Set; | ||
// | ||
//import android.content.SharedPreferences; | ||
//import android.preference.PreferenceManager; | ||
//import android.test.ServiceTestCase; | ||
//import android.test.suitebuilder.annotation.SmallTest; | ||
// | ||
//import com.openxc.util.SupportSettingsUtils; | ||
// | ||
//public class SupportSettingsUtilsTests extends ServiceTestCase<VehicleManager> { | ||
// SharedPreferences preferences; | ||
// Set<String> value; | ||
// String key = "mykey"; | ||
// | ||
// public SupportSettingsUtilsTests() { | ||
// super(VehicleManager.class); | ||
// } | ||
// | ||
// @Override | ||
// protected void setUp() throws Exception { | ||
// super.setUp(); | ||
// preferences = PreferenceManager.getDefaultSharedPreferences(getContext()); | ||
// SharedPreferences.Editor editor = preferences.edit(); | ||
// editor.clear(); | ||
// editor.commit(); | ||
// value = new HashSet<String>(); | ||
// value.add("abcd"); | ||
// value.add("1234"); | ||
// value.add("zxy"); | ||
// } | ||
// | ||
// @SmallTest | ||
// public void testStoreRetreiveStringSet() { | ||
// SharedPreferences.Editor editor = preferences.edit(); | ||
// SupportSettingsUtils.putStringSet(editor, key, value); | ||
// editor.commit(); | ||
// assertEquals(value, SupportSettingsUtils.getStringSet( | ||
// preferences, key, new HashSet<String>())); | ||
// } | ||
// | ||
// @SmallTest | ||
// public void testRetreiveInvalidKeyStringSet() { | ||
// assertEquals(new HashSet<String>(), SupportSettingsUtils.getStringSet( | ||
// preferences, key, new HashSet<String>())); | ||
// } | ||
//} | ||
// | ||
package com.openxc; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import android.content.SharedPreferences; | ||
import android.preference.PreferenceManager; | ||
import android.test.ServiceTestCase; | ||
import android.test.suitebuilder.annotation.SmallTest; | ||
|
||
import com.openxc.util.SupportSettingsUtils; | ||
|
||
public class SupportSettingsUtilsTests extends ServiceTestCase<VehicleManager> { | ||
SharedPreferences preferences; | ||
Set<String> value; | ||
String key = "mykey"; | ||
|
||
public SupportSettingsUtilsTests() { | ||
super(VehicleManager.class); | ||
} | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
preferences = PreferenceManager.getDefaultSharedPreferences(getContext()); | ||
SharedPreferences.Editor editor = preferences.edit(); | ||
editor.clear(); | ||
editor.commit(); | ||
value = new HashSet<String>(); | ||
value.add("abcd"); | ||
value.add("1234"); | ||
value.add("zxy"); | ||
} | ||
|
||
@SmallTest | ||
public void testStoreRetreiveStringSet() { | ||
SharedPreferences.Editor editor = preferences.edit(); | ||
SupportSettingsUtils.putStringSet(editor, key, value); | ||
editor.commit(); | ||
assertEquals(value, SupportSettingsUtils.getStringSet( | ||
preferences, key, new HashSet<String>())); | ||
} | ||
|
||
@SmallTest | ||
public void testRetreiveInvalidKeyStringSet() { | ||
assertEquals(new HashSet<String>(), SupportSettingsUtils.getStringSet( | ||
preferences, key, new HashSet<String>())); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
//package com.openxc; | ||
// | ||
//import static org.junit.Assert.*; | ||
// | ||
//import java.io.File; | ||
//import java.io.IOException; | ||
//import java.net.URI; | ||
//import java.net.URISyntaxException; | ||
// | ||
//import org.apache.commons.io.FileUtils; | ||
// | ||
//import android.content.Context; | ||
// | ||
//public class TestUtils { | ||
// public static void pause(int millis) { | ||
// try { | ||
// Thread.sleep(millis); | ||
// } catch(InterruptedException e) {} | ||
// } | ||
// | ||
// public static URI copyToStorage(Context context, int resource, | ||
// String filename) { | ||
// URI uri = null; | ||
// try { | ||
// uri = new URI("file:///sdcard/com.openxc/" + filename); | ||
// } catch(URISyntaxException e) { | ||
// fail("Couldn't construct resource URIs: " + e); | ||
// } | ||
// | ||
// try { | ||
// FileUtils.copyInputStreamToFile( | ||
// context.getResources().openRawResource(resource), | ||
// new File(uri)); | ||
// } catch(IOException e) { | ||
// fail("Couldn't copy trace files to SD card" + e); | ||
// } | ||
// return uri; | ||
// } | ||
// | ||
//} | ||
package com.openxc; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.net.URISyntaxException; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
|
||
import android.content.Context; | ||
|
||
public class TestUtils { | ||
public static void pause(int millis) { | ||
try { | ||
Thread.sleep(millis); | ||
} catch(InterruptedException e) {} | ||
} | ||
|
||
public static URI copyToStorage(Context context, int resource, | ||
String filename) { | ||
URI uri = null; | ||
try { | ||
uri = new URI("file:///sdcard/com.openxc/" + filename); | ||
} catch(URISyntaxException e) { | ||
fail("Couldn't construct resource URIs: " + e); | ||
} | ||
|
||
try { | ||
FileUtils.copyInputStreamToFile( | ||
context.getResources().openRawResource(resource), | ||
new File(uri)); | ||
} catch(IOException e) { | ||
fail("Couldn't copy trace files to SD card" + e); | ||
} | ||
return uri; | ||
} | ||
|
||
} |
Oops, something went wrong.