Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test scripts for kitkit launcher app. #16

Open
wants to merge 24 commits into
base: auto-testing
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6045cad
Initial commit
May 28, 2019
f9a735b
Merge branch 'newmaster' into AyushM/KitkitTestingFramework
May 28, 2019
42c0c19
Fixed the type of the variable
May 28, 2019
89ffdfd
Added English game titles along with Hindi
May 28, 2019
708665f
Added 7 sub Test Cases
May 28, 2019
62a842c
Adjusted the font of English text
May 29, 2019
2545afb
Chnaged the image of the splash screen
May 29, 2019
466c19b
Updated the number of coin
May 29, 2019
f43207b
Merge branch 'newmaster' into PrabhatT/FixSplashScreenProgress
May 29, 2019
eb5e756
Added English text to tools section and put English text above Hindi
May 29, 2019
52d2d47
Updated the package name required for SeaWorld
May 29, 2019
c8d9254
added all the test cases for launcher
May 29, 2019
278d3a9
Merge branch 'newmaster' into AyushM/KitkitTestingFramework
May 29, 2019
29f90a7
Renamed file name
May 30, 2019
a686716
Centre aligned the text- Start
May 30, 2019
88c79ed
Some fixes
May 30, 2019
bffc73b
Optimized the splash screen background
May 30, 2019
08dd743
Optimized the size of the splash screen background
May 30, 2019
db2f0a3
Updated the version and variable name
May 30, 2019
e46bb55
Removed unused module and changed the variable name
May 30, 2019
8aa9ec3
Merge pull request #14 from maqsoftware/PrabhatT/FixSplashScreenProgress
May 30, 2019
4cfdd30
Merge pull request #12 from maqsoftware/MeghnaP
pai-meghna May 30, 2019
cb2fa0f
updated permission function.
May 31, 2019
ade6e0d
Merge branch 'newmaster' into AyushM/KitkitTestingFramework
May 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions kitkitschoollogger/kitkitlogger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apply plugin: 'com.android.library'
android {
publishNonDefault true

compileSdkVersion 25
buildToolsVersion "25.0.3"
compileSdkVersion 28
buildToolsVersion "28.0.3"

defaultConfig {
minSdkVersion 16
targetSdkVersion 25
targetSdkVersion 28
versionCode 1
versionName "1.0"

Expand Down
2 changes: 2 additions & 0 deletions kitkitschoollogger/kitkitlogger/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"

package="com.maq.kitkitlogger">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Expand All @@ -10,4 +11,5 @@

</application>


</manifest>
11 changes: 9 additions & 2 deletions launcher/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ android {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
Expand All @@ -85,7 +85,14 @@ dependencies {
compile files('libs/commons-io-2.5.jar')
compile 'org.apmem.tools:layouts:1.10@aar'
compile project(':kitkitlogger')
compile "com.android.support:appcompat-v7:25.0.+"

compile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
compile 'com.android.support.test:runner:0.5'
compile 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.android.support.test:rules:1.0.2'
// compile 'com.android.support.test.espresso:espresso-intents:2.2'


//englishCompile project(path: ':kitkitlogger', configuration: 'englishRelease')
//swahiliCompile project(path: ':kitkitlogger', configuration: 'swahiliRelease')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
package com.maq.xprize.kitkitlauncher.hindi;



import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.rule.GrantPermissionRule;
import android.support.test.runner.AndroidJUnit4;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static android.support.test.InstrumentationRegistry.getInstrumentation;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import android.os.Build;
import android.util.Log;
import java.io.File;

@LargeTest
@RunWith(AndroidJUnit4.class)
public class Test_Allow {
private static final int MAIN_APP_BUTTON_INSTANCE= 1;
private static final int LIBRARY_BUTTON_INSTANCE = 2;
private static final int TOOL_BUTTON_INSTANCE= 3;
private static final int CROSS_TILE_BUTTON_INSTANCE = 0;
private static final int INSTALL_BUTTON_INSTANCE = 1;
private static final int BACK_ARROW_INSTANCE= 0;
private static final int TOOL_1_INSTANCE= 1;
private static final int TOOL_2_INSTANCE= 2;
private static final int TOOL_3_INSTANCE= 3;
private static final int TOOL_4_INSTANCE= 4;
private static final int TOOL_5_INSTANCE= 5;
private static final int TOOL_6_INSTANCE= 6;
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule(MainActivity.class);
// @Rule
// public GrantPermissionRule mGrantPermissionRule =
// GrantPermissionRule.grant(
// "android.permission.READ_EXTERNAL_STORAGE");
///////////////////////////////////////////////// Test case /////////////////////////
@Test
public void ALLOW_TESTS() {

// takess(1);
permission(1);
ismainsmenuvisible();
waitfortime(2000);
clickTest(LIBRARY_BUTTON_INSTANCE);
// takess(2);
isvideomenuvisible();
waitfortime(2000);
clickTest(CROSS_TILE_BUTTON_INSTANCE);
waitfortime(2000);
clickTest(LIBRARY_BUTTON_INSTANCE);
isvideomenuvisible();
waitfortime(2000);
clickTest(INSTALL_BUTTON_INSTANCE);
waitfortime(2000);
clickback();
waitfortime(2000);
ismainsmenuvisible();
waitfortime(2000);
clickTest(MAIN_APP_BUTTON_INSTANCE);
waitfortime(10000);
permission(1);
permission(1);
waitfortime(2000);
clickback();
// permission(1);
// clickTest(CROSS_TILE_BUTTON_INSTANCE);
// waitfortime(2000);
// clickTest(MAIN_APP_BUTTON_INSTANCE);
// isvideomenuvisible();
// waitfortime(2000);
// clickTest(INSTALL_BUTTON_INSTANCE);
// waitfortime(2000);
// clickback();
waitfortime(2000);
clickTest(TOOL_BUTTON_INSTANCE);
// takess(3);
istoolsmenuvisible();
waitfortime(1000);
clickTest(TOOL_1_INSTANCE);
waitfortime(1000);
clickback();
waitfortime(1000);
clickTest(TOOL_2_INSTANCE);
waitfortime(1000);
clickback();
waitfortime(1000);
clickTest(TOOL_3_INSTANCE);
waitfortime(1000);
clickback();
waitfortime(1000);
clickTest(TOOL_4_INSTANCE);
waitfortime(1000);
clickback();
waitfortime(1000);
clickTest(TOOL_5_INSTANCE);
waitfortime(1000);
clickback();
waitfortime(1000);
clickTest(TOOL_6_INSTANCE);
waitfortime(1000);
clickback();
waitfortime(2000);
clickTest(BACK_ARROW_INSTANCE);
// takess(4);
// Test_Video VideoObj = new Test_Video();
//
// VideoObj.VIDEO_TESTS();

}



private void clickTest(int INSTANCE_NUMBER){ /// click on defined element

try {

UiDevice device = UiDevice.getInstance(getInstrumentation());
UiObject allowPermissions = device.findObject(new UiSelector()
.clickable(true)
.checkable(false)
.instance(INSTANCE_NUMBER));
if (allowPermissions.exists()) {
allowPermissions.click();
}else {
Log.d("Instance","Does Not Exist");
}

} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}

}

private void waitfortime(int TIME){ // wait for mili second
try {
Thread.sleep(TIME);
} catch (InterruptedException e) {
e.printStackTrace();
}

}
private void clickback(){ /// click mobiles back button
UiDevice device = UiDevice.getInstance(getInstrumentation());
device.pressBack();
}

private void ismainsmenuvisible(){
onView(withId(R.id.button_todoschool)).check(matches(isDisplayed()));
onView(withId(R.id.button_library)).check(matches(isDisplayed()));
onView(withId(R.id.button_tool)).check(matches(isDisplayed()));
onView(withId(R.id.textView_currentUserId)).check(matches(isDisplayed()));
onView(withId(R.id.launcher_title_button)).check(matches(isDisplayed()));
onView(withId(R.id.textView_numCoin)).check(matches(isDisplayed()));
onView(withId(R.id.imageView_coin)).check(matches(isDisplayed()));
}

private void istoolsmenuvisible(){
onView(withId(R.id.image_coin)).check(matches(isDisplayed()));
onView(withId(R.id.textView_numCoin)).check(matches(isDisplayed()));
onView(withId(R.id.app_drum)).check(matches(isDisplayed()));
onView(withId(R.id.app_marimba)).check(matches(isDisplayed()));
onView(withId(R.id.app_blackboard)).check(matches(isDisplayed()));
onView(withId(R.id.app_coloring)).check(matches(isDisplayed()));
onView(withId(R.id.app_drawing)).check(matches(isDisplayed()));
onView(withId(R.id.app_album)).check(matches(isDisplayed()));
onView(withId(R.id.app_fish_bowl)).check(matches(isDisplayed()));
onView(withId(R.id.app_writing_board)).check(matches(isDisplayed()));
}

private void isvideomenuvisible(){
onView(withId(R.id.installAppButton)).check(matches(isDisplayed()));
onView(withId(R.id.videoCloseButton)).check(matches(isDisplayed()));
onView(withId(R.id.videoSurface)).check(matches(isDisplayed()));
}
private void permission(int action) {
if (Build.VERSION.SDK_INT >= 23) {
if (action == 0) {
UiObject denyPermissions = UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("Deny"));
if (denyPermissions.exists()) {
try {
denyPermissions.click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
}else{
UiObject Permissions = UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("DENY"));
if (Permissions.exists()) {
try {
Permissions.click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
}
}
}else if (action == 1){
UiObject allowPermissions = UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("Allow"));
if (allowPermissions.exists()) {
try {
allowPermissions.click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
}else{
UiObject Permissions = UiDevice.getInstance(getInstrumentation()).findObject(new UiSelector().text("ALLOW"));
if (Permissions.exists()) {
try {
Permissions.click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
}
}

}
}
}

private void takess(int i){ // takes screen shot of instance
File path = new File("/sdcard/test-screenshots/ALLOW_TESTS" + Integer.toString(i));
int SDK_VERSION = android.os.Build.VERSION.SDK_INT;
if (SDK_VERSION >= 17) {
waitfortime(1000);
UiDevice.getInstance(getInstrumentation()).takeScreenshot(path);
waitfortime(1000);
}
}
// @After
// public void intentsTeardown() {
//// release Espresso Intents capturing
// Intents.release();
// }



}

Loading