mirror of
https://github.com/android-password-store/Android-Password-Store.git
synced 2025-09-07 16:09:38 +02:00
starting to write tests
This commit is contained in:
parent
3ca806d699
commit
78a2494d5e
|
@ -1,13 +0,0 @@
|
||||||
package com.zeapo.pwdstore;
|
|
||||||
|
|
||||||
import android.app.Application;
|
|
||||||
import android.test.ApplicationTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
|
||||||
*/
|
|
||||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
|
||||||
public ApplicationTest() {
|
|
||||||
super(Application.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.zeapo.pwdstore;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Instrumentation;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
import android.test.ActivityTestCase;
|
||||||
|
import android.test.InstrumentationTestCase;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.zeapo.pwdstore.git.GitActivity;
|
||||||
|
|
||||||
|
public class GitActivityTest extends ActivityInstrumentationTestCase2<GitActivity> {
|
||||||
|
private Activity gitActivity;
|
||||||
|
private Instrumentation mInstrumentation;
|
||||||
|
private SharedPreferences settings;
|
||||||
|
|
||||||
|
private Spinner protocolSpinner;
|
||||||
|
private Spinner connectionModeSpinner;
|
||||||
|
private EditText uri;
|
||||||
|
private EditText server_url;
|
||||||
|
private EditText server_port;
|
||||||
|
private EditText server_path;
|
||||||
|
private EditText server_user;
|
||||||
|
|
||||||
|
public GitActivityTest() {
|
||||||
|
super(GitActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
mInstrumentation = getInstrumentation();
|
||||||
|
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra("Operation", GitActivity.EDIT_SERVER);
|
||||||
|
setActivityIntent(intent);
|
||||||
|
|
||||||
|
gitActivity = getActivity(); // get a references to the app under test
|
||||||
|
assertNotNull(gitActivity);
|
||||||
|
|
||||||
|
settings = PreferenceManager.getDefaultSharedPreferences(gitActivity.getApplicationContext());
|
||||||
|
|
||||||
|
uri = (EditText) gitActivity.findViewById(R.id.clone_uri);
|
||||||
|
server_url = ((EditText) gitActivity.findViewById(R.id.server_url));
|
||||||
|
server_port = ((EditText) gitActivity.findViewById(R.id.server_port));
|
||||||
|
server_path = ((EditText) gitActivity.findViewById(R.id.server_path));
|
||||||
|
server_user = ((EditText) gitActivity.findViewById(R.id.server_user));
|
||||||
|
protocolSpinner = (Spinner) gitActivity.findViewById(R.id.clone_protocol);
|
||||||
|
connectionModeSpinner = (Spinner) gitActivity.findViewById(R.id.connection_mode);
|
||||||
|
|
||||||
|
assertEquals(protocolSpinner.getSelectedItem(), settings.getString("git_remote_protocol", "ssh://"));
|
||||||
|
assertEquals(connectionModeSpinner.getSelectedItem(), settings.getString("git_remote_auth", "ssh-key"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If we change from ssh protocol to https we automatically switch to username/password auth
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public void testSpinnerChange() throws Exception{
|
||||||
|
gitActivity.runOnUiThread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
protocolSpinner.requestFocus();
|
||||||
|
protocolSpinner.setSelection(1); // 1 < is https://
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mInstrumentation.waitForIdleSync();
|
||||||
|
|
||||||
|
assertEquals(connectionModeSpinner.getSelectedItem(), "username/password"); // 1 < is username/password
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue