Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 31 additions & 17 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def matrix = [
'target': 'i686-linux-android',
'test': true,
],
'cliqz-alpha':[
/*'cliqz-alpha':[
'bundleid': 'com.cliqz.browser.alpha',
'target': 'arm-linux-androideabi',
'test': false,
],
],*/
'ghostery-alpha':[
'bundleid': 'com.ghostery.android.alpha',
'target': 'arm-linux-androideabi',
Expand All @@ -35,14 +35,14 @@ def build(Map m){
def apk = ""
def testsFolder = "cliqz-mobile-tests"
setupTestInstance(
test,
"ami-6c24fc11",
"1",
"t2.medium",
"android_ci_genymotion",
"sg-5bbf173f",
"subnet-341ff61f",
"us-east-1"
test, // Boolean value for Running Tests
"ami-6c24fc11", // Amazon AWS AMI ID
"1", // Count, Number of Instances
"t2.medium", // Instance Size
"android_ci_genymotion", // RSA Key
"sg-5bbf173f", // Secutiry Group ID of AWS
"subnet-341ff61f", // Subnet ID for the instance
"us-east-1" // AWS Region
) {
try {
stage('Checkout') {
Expand All @@ -55,10 +55,14 @@ def build(Map m){
image.pull()
image.inside {
stage('Build Cliqz React Native') {
cliqz.buildCliqzReactNative("cliqz")
cliqz.buildCliqzReactNative("cliqz") // Pass the Folder Name for the React Native SRC
}
stage("Build APK: ${flavorname}") {
apk = cliqz.buildBrowser("${androidtarget}", "${flavorname}", "ci")
apk = cliqz.buildBrowser(
"${androidtarget}", // Target for the build
"${flavorname}", // Name of the Flavor
"ci" // Type of the Build (CI, Nightly or Release)
)
archiveArtifacts allowEmptyArchive: true, artifacts: "build/${apk}"
}
}
Expand All @@ -78,12 +82,22 @@ def build(Map m){
"FLAVOR=${flavorname}",
"appPackage=${bundleid}"
]) {
stage('Genymotion ADB Connect') {
genymotion.connectGenyInstance('da5f91e6-e1ca-4aac-94ea-352b6769228b')
stage('Set Genymotion Resolution and Connect') {
genymotion.genySetPhoneResolution('da5f91e6-e1ca-4aac-94ea-352b6769228b') // Pass the Credentials ID for the AWS API Key
genymotion.connectGenyInstance('da5f91e6-e1ca-4aac-94ea-352b6769228b') // Pass the Credentials ID for the AWS API Key
}
stage("Run UIA2 Tests & Upload Results: ${flavorname}"){
timeout(10){
cliqz.runUITests("${flavorname}") // Pass the Flavor Name for running the UIAutomator Tests
}
}
stage("Run Tests & Upload Results: ${flavorname}") {
stage("Run Appium Tests & Upload Results: ${flavorname}") {
timeout(60) {
cliqz.runAppiumTests("${testsFolder}", "${flavorname}", "${apk}")
cliqz.runAppiumTests(
"${testsFolder}", // Path to the Folder where the Tests are cloned.
"${flavorname}", // Flavor Name for running the UIAutomator Tests
"${apk}" // Path to the APK used for testing.
)
}
}
}
Expand All @@ -95,7 +109,7 @@ def build(Map m){
error 'Something Failed ! Check Logs above.'
} finally {
stage('Clean Up') {
utils.cleanUp("${testsFolder}")
utils.cleanUp("${testsFolder}") // Path to the Folder where the Tests are cloned. This will delete the Tests Folder.
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile.docker
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ node('us-east-1 && ubuntu && docker && !gpu') {
}

def baseImageName = "browser-f/android:${dockerTag}"

stage('Build Create Docker Image') {
docker.withRegistry('https://141047255820.dkr.ecr.us-east-1.amazonaws.com'){
def baseImage = docker.build(baseImageName, '--build-arg USER=`whoami` --build-arg UID=`id -u` --build-arg GID=`id -g` .')
Expand Down
3 changes: 2 additions & 1 deletion mozconfigs/jenkins.mozconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Build Firefox for Android:
# Add MOZILLA_OFFICIAL flag to proguard the artifacts
MOZILLA_OFFICIAL=1
# MOZILLA_OFFICIAL=1

# Android Targets: 'i686-linux-android' or 'arm-linux-androideabi'
ac_add_options --enable-application=mobile/android
ac_add_options --target=$ANDROID_TARGET

# With the following Android SDK:
ac_add_options --with-android-sdk=$ANDROID_HOME
ac_add_options --with-android-min-sdk=21

# Allow artifact builds:
ac_add_options --enable-artifact-builds
Expand Down
1 change: 1 addition & 0 deletions mozilla-release/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ buildscript {
url repository
}
}
google()
}

ext.kotlin_version = '1.2.41'
Expand Down
36 changes: 32 additions & 4 deletions mozilla-release/mobile/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ android {
ndk {
abiFilters mozconfig.substs.ANDROID_CPU_ARCH.toString()
}
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// testInstrumentationRunner 'org.mozilla.gecko.FennecInstrumentationTestRunner'
// Used by Robolectric based tests; see TestRunner.
/* Cliqz end */
applicationId mozconfig.substs.ANDROID_PACKAGE_NAME
testApplicationId 'org.mozilla.roboexample.test'
testInstrumentationRunner 'org.mozilla.gecko.FennecInstrumentationTestRunner'
// Used by Robolectric based tests; see TestRunner.
buildConfigField 'String', 'BUILD_DIR', "\"${project.buildDir}\""
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -214,7 +214,11 @@ android {
}

androidTest {
java {
/* Cliqz Start :: Cliqz Android Tests */
java {
srcDir "${topsrcdir}/mobile/android/tests/cliqz/java"
}
/*java {
srcDir "${topsrcdir}/mobile/android/tests/browser/robocop/src"
// Bug 1229149 tracks pushing this into a :services Gradle project.
srcDir "${topsrcdir}/mobile/android/services/src/androidTest/java"
Expand All @@ -226,6 +230,7 @@ android {
assets {
srcDir "${topsrcdir}/mobile/android/tests/browser/robocop/assets"
}
/o Cliqz End */
}
}

Expand Down Expand Up @@ -289,7 +294,9 @@ dependencies {
implementation project(path: ':thirdparty')

testImplementation 'junit:junit:4.12'
/* Cliqz Start o/
testImplementation 'org.robolectric:robolectric:3.8'
/o Cliqz End */
testImplementation 'org.simpleframework:simple-http:6.0.1'
testImplementation 'org.mockito:mockito-core:1.10.19'

Expand All @@ -299,6 +306,9 @@ dependencies {
/*Cliqz Start*/
//Library for control center donut - chart
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
//UIAutomator2 Dependencies
androidTestImplementation 'com.android.support.test:testing-support-lib:0.1'
androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
/*Cliqz End*/

}
Expand Down Expand Up @@ -608,3 +618,21 @@ if (mozconfig.substs.MOZ_JAVA_CODE_COVERAGE) {
}
}
}
/* Cliqz Start */
// Grant permissions to disable Animations.
task grantAnimationPermissions(type: Exec, dependsOn: 'installWithGeckoBinariesDebug') {
group = 'Verification tasks'
description = 'Grant permissions for testing.'
def appPackage = mozconfig.substs.ANDROID_PACKAGE_NAME
def androidHome = mozconfig.substs.ANDROID_SDK_ROOT
commandLine "$androidHome/platform-tools/adb shell pm grant $appPackage android.permission.SET_ANIMATION_SCALE".split(" ")
}

afterEvaluate {
tasks.each { task ->
if (task.name.contains('connectedWithGeckoBinariesDebugAndroidTest')) {
task.dependsOn grantAnimationPermissions
}
}
}
/* Cliqz End */
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Cliqz Start -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.mozilla.roboexample.test"
package="com.cliqz.mobile.test"
android:sharedUserId="${MOZ_ANDROID_SHARED_ID}"
android:versionCode="1"
android:versionName="1.0" >
<!-- NOTE: Replaced package name. package="org.mozilla.roboexample.test" Cliqz End -->

<uses-sdk android:minSdkVersion="${MOZ_ANDROID_MIN_SDK_VERSION}"
android:targetSdkVersion="${ANDROID_TARGET_SDK}"/>
<!-- TODO: re-instate maxSdkVersion. -->

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<instrumentation
android:name="org.mozilla.gecko.FennecInstrumentationTestRunner"
android:targetPackage="${ANDROID_PACKAGE_NAME}" />

<!-- Cliqz Start -+>
<application
android:label="@string/app_name"> -->
<application
android:label="@string/app_name">
android:label="Instrumentation Test">
<!-- Cliqz End -->

<uses-library android:name="android.test.runner" />

Expand Down
1 change: 1 addition & 0 deletions mozilla-release/mobile/android/base/AndroidManifest.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifdef MOZ_ANDROID_SHARED_ID
android:sharedUserId="@MOZ_ANDROID_SHARED_ID@"
#endif
<uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/>
<! - Cliqz End -->
<uses-sdk android:minSdkVersion="@MOZ_ANDROID_MIN_SDK_VERSION@"
#ifdef MOZ_ANDROID_MAX_SDK_VERSION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@
<uses-feature android:name="android.hardware.nfc" android:required="false"/>
#endif

#ifndef MOZILLA_OFFICIAL
<uses-permission android:name="android.permission.SET_ANIMATION_SCALE" />
<uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" />
#endif

#ifdef MOZ_WEBRTC
<uses-feature android:name="android.hardware.audio.low_latency" android:required="false"/>
<uses-feature android:name="android.hardware.camera.any" android:required="false"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package com.cliqz.mobile.test;

import android.util.Log;

import org.junit.Ignore;
import org.junit.internal.AssumptionViolatedException;
import org.junit.internal.runners.model.EachTestNotifier;
import org.junit.runner.Description;
import org.junit.runner.notification.RunNotifier;
import org.junit.runner.notification.StoppedByUserException;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.model.Statement;

/**
* Copyright © Cliqz 2019
*/
public class CliqzRunner extends BlockJUnit4ClassRunner {

private static final int RETRY_COUNT = 2;

public CliqzRunner(Class<?> clazz) throws InitializationError {
super(clazz);
}

@Override
public void run(final RunNotifier notifier) {
final EachTestNotifier testNotifier = new EachTestNotifier(notifier, getDescription());
Statement statement = classBlock(notifier);
try {
statement.evaluate();
} catch (AssumptionViolatedException ave) {
testNotifier.fireTestIgnored();
} catch (StoppedByUserException sbue) {
throw sbue;
} catch (Throwable t) {
Log.w("AUTOBOTS", "Retry class: " + getDescription().getDisplayName());
retry(testNotifier, statement, t, getDescription());
}
}

@Override
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
final Description description = describeChild(method);
if (method.getAnnotation(Ignore.class) != null) {
notifier.fireTestIgnored(description);
} else {
runTest(methodBlock(method), description, notifier);
}
}

private void runTest(Statement statement, Description description, RunNotifier notifier) {
final EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
eachNotifier.fireTestStarted();
try {
statement.evaluate();
} catch (AssumptionViolatedException e) {
eachNotifier.addFailedAssumption(e);
} catch (Throwable e) {
Log.w("AUTOBOTS", "Retry test: " + description.getDisplayName());
retry(eachNotifier, statement, e, description);
} finally {
eachNotifier.fireTestFinished();
}
}

private void retry(EachTestNotifier notifier, Statement statement, Throwable currentThrowable, Description info) {
int failedAttempts = 0;
Throwable caughtThrowable = currentThrowable;
while (RETRY_COUNT > failedAttempts) {
try {
notifier.fireTestIgnored();
notifier.fireTestStarted();
Log.w("AUTOBOTS", "Retry attempt " + (failedAttempts + 1) + " for " + info.getDisplayName());
statement.evaluate();
notifier.fireTestFinished();
return;
} catch (Throwable t) {
failedAttempts++;
caughtThrowable = t;
}
}
Log.e("AUTOBOTS", caughtThrowable.getMessage());
notifier.addFailure(caughtThrowable);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.cliqz.mobile.test.driver;

import android.support.test.uiautomator.UiObject2;
import android.util.Log;

/**
* Copyright © Cliqz 2019
*/
public class ElementData {

private UiObject2 element;
private boolean exists;
private boolean checked;
private boolean enabled;
private boolean focused;
private boolean selected;
private String text;
private String description;


public ElementData(UiObject2 elem) {
element = elem;
try {
exists = element.getResourceName()!=null;
text = element.getText();
description = element.getContentDescription();
checked = element.isChecked();
enabled = element.isEnabled();
focused = element.isFocused();
selected = element.isSelected();
} catch (Exception e) {
Log.w("AUTOBOTS", e.toString());
}
}

public boolean hasChanged() {
ElementData tempData = new ElementData(element);
return this != tempData;
}

}
Loading