Loren M. Lang 2025-02-09 08:07:56 +08:00 zatwierdzone przez GitHub
commit 74e63a6177
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
5 zmienionych plików z 81 dodań i 12 usunięć

Wyświetl plik

@ -1,15 +1,15 @@
package org.aprsdroid.app;
import static org.junit.Assert.assertEquals;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*

Wyświetl plik

@ -0,0 +1,55 @@
package org.aprsdroid.app;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasAction;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.Matchers.allOf;
import static org.junit.Assume.assumeTrue;
import android.Manifest;
import android.app.Instrumentation;
import android.content.Intent;
import android.os.Environment;
import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.intent.Intents;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.GrantPermissionRule;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class ProfileTests {
@Rule
public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
@Before
public void setUp() {
Intents.init();
}
@After
public void tearDown() {
Intents.release();
}
@Test
public void testThatExportProfileOpensTheChooser() {
assumeTrue(Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()));
ActivityScenario scenario = ActivityScenario.launch(PrefsAct.class);
Intents.intending(hasAction(Intent.ACTION_CHOOSER)).respondWith(new Instrumentation.ActivityResult(0, null));
openActionBarOverflowOrOptionsMenu(InstrumentationRegistry.getInstrumentation().getTargetContext());
onView(withText(R.string.profile_export))
.perform(click());
Intents.intended(hasAction(Intent.ACTION_MAIN)); // Validate the activity launch
Intents.intended(allOf(hasAction(Intent.ACTION_CHOOSER)));
Intents.assertNoUnverifiedIntents();
}
}

Wyświetl plik

@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.android.tools.build:gradle:3.5.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@ -81,7 +81,7 @@ android {
resValue "string", "google_maps_key", mapsApiKey()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
useLibrary 'org.apache.http.legacy'
compileOptions {
@ -158,7 +158,13 @@ dependencies {
implementation 'com.squareup.okio:okio:2.1.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.hamcrest:hamcrest-core:1.3'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
}

Wyświetl plik

@ -1,3 +1,4 @@
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="APRSdroid" path="Documents/APRSdroid" />
<external-path name="APRSdroid-top" path="APRSdroid" />
</paths>

Wyświetl plik

@ -9,6 +9,8 @@ import _root_.android.preference.PreferenceActivity
import _root_.android.preference.PreferenceManager
import _root_.android.view.{Menu, MenuItem}
import _root_.android.widget.Toast
import android.util.Log
import java.text.SimpleDateFormat
import java.io.{File, PrintWriter}
import java.util.Date
@ -16,6 +18,8 @@ import java.util.Date
import org.json.JSONObject
class PrefsAct extends PreferenceActivity {
val TAG = "APRSdroid.PrefsAct"
lazy val db = StorageDatabase.open(this)
lazy val prefs = new PrefsWrapper(this)
@ -33,7 +37,10 @@ class PrefsAct extends PreferenceActivity {
UIHelper.shareFile(this, file, filename)
} catch {
case e : Exception => Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show()
case e : Exception => {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show()
Log.i(TAG, "Caught exception sharing file: " + e, e)
}
}
}
@ -62,7 +69,7 @@ class PrefsAct extends PreferenceActivity {
def resolveContentUri(uri : Uri) = {
val Array(storage, path) = uri.getPath().replace("/document/", "").split(":", 2)
android.util.Log.d("PrefsAct", "resolveContentUri s=" + storage + " p=" + path)
android.util.Log.d(TAG, "resolveContentUri s=" + storage + " p=" + path)
if (storage == "primary")
Environment.getExternalStorageDirectory() + "/" + path
else
@ -108,7 +115,7 @@ class PrefsAct extends PreferenceActivity {
}
override def onActivityResult(reqCode : Int, resultCode : Int, data : Intent) {
android.util.Log.d("PrefsAct", "onActResult: request=" + reqCode + " result=" + resultCode + " " + data)
android.util.Log.d(TAG, "onActResult: request=" + reqCode + " result=" + resultCode + " " + data)
if (resultCode == android.app.Activity.RESULT_OK && reqCode == 123456) {
//parseFilePickerResult(data, "mapfile", R.string.mapfile_error)
val takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)