Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
betty committed Mar 9, 2016
0 parents commit 29c7711
Show file tree
Hide file tree
Showing 28 changed files with 959 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gradle
local.properties
.idea
.DS_Store
build
*.iml
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Basic sample for UiAutomator

*If you are new to UiAutomator, try this sample first.*

This project uses the Gradle build system. You don't need an IDE to build and execute it but Android Studio is recommended.

1. Download the project code, preferably using `git clone`.
1. Open the Android SDK Manager (*Tools* Menu | *Android*) and make sure you have installed the *Android testing support library Repository* under *Extras*.
1. In Android Studio, select *File* | *Open...* and point to the `./build.gradle` file.
1. Check out the relevant code:
* The application under test is located in `src/main/java`
* Tests are in `src/androidTest/java`
1. Create the test configuration with a custom runner: `android.support.test.runner.AndroidJUnitRunner`
* Open *Run* menu | *Edit Configurations*
* Add a new *Android Tests* configuration
* Choose a module
* Add a *Specific instrumentation runner*: `android.support.test.runner.AndroidJUnitRunner`
1. Run the newly created configuration

The application will be started on the device/emulator and a series of actions will be performed automatically.

If you are using Android Studio, the *Run* window will show the test results.
35 changes: 35 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.example.android.testing.uiautomator.contactstest"
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'LICENSE.txt'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}

dependencies {
compile 'com.google.guava:guava:18.0'
// Testing-only dependencies
androidTestCompile 'com.android.support.test:runner:0.3'
// UiAutomator Testing
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
androidTestCompile 'org.hamcrest:hamcrest-integration:1.3'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.android.testing.uiautomator.contactstest;

/**
* Created by betty on 7/12/15.
*/
public class BaseFunctionTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package com.example.android.testing.uiautomator.contactstest;

/**
* Created by betty on 6/30/15.
*/


import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;

/**
* 1.back to home
* 2.UiScrollable to pag 2
* 3.press contacts
* 4.press local contacts
* 5.press menu
* 6.press download
* 7.UiSelector text download server
* 8.clearTextField then setText("http://192.168.120.242/TEST_DATA/Contacts/GXP2200/contacts/1001_utf8.xml")
* 9.press download
* 10.back
* 11.press contacts
*/
public class BugVerifyTest extends Unit {


//bug1111
public void bug1111(){


}

public void p1BugVerify(){


}

public void p2BugVerify(){


}

public void p3BugVerify(){


}

/**
* verify the bug read from bug.xml
**/

public void bugListVerify(String url){
try
{ Scanner s = new Scanner( new File("/data/bug.txt") );
while( s.hasNextInt() )
{
System.out.println( s.nextInt() );
//java reflect

}
}
catch(IOException e)
{ System.out.println( e );

}

}

public void bugListDownload(String bugUrl){
String bugFileUrl = bugUrl;
String pathName="/data/bug.txt";
OutputStream output=null;
try {
URL url=new URL(bugFileUrl);
HttpURLConnection conn=(HttpURLConnection)url.openConnection();
File file=new File(pathName);
InputStream input=conn.getInputStream();
if(file.exists()){
System.out.println("exits");
return;
}else{
String dir="/data";
new File(dir).mkdir();
file.createNewFile();
output=new FileOutputStream(file);
byte[] buffer=new byte[4*1024];
while(input.read(buffer)!=-1){
output.write(buffer);
}
output.flush();
}
} catch (Exception e) {
e.printStackTrace();
} finally{
try {
output.close();
System.out.println("success");
} catch (Exception e) {
System.out.println("fail");
e.printStackTrace();
}
}




}




}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.example.android.testing.uiautomator.contactstest;

//import org.junit.Test;


import android.test.InstrumentationTestSuite;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

/**
* Created by betty on 6/30/15.
*/

@RunWith(Suite.class)
@Suite.SuiteClasses({BaseFunctionTest.class,BugVerifyTest.class})
public class ContactsTest {

// public void testRunTestSuites() throws UiObjectNotFoundException {
// TestSuite suite = new TestSuite();
// suite.addTestSuite(BugVerifyTest.class);
// }
}
Loading

0 comments on commit 29c7711

Please sign in to comment.