Skip to content

Commit

Permalink
Merge pull request #51 from ademcan/master
Browse files Browse the repository at this point in the history
v1.0.8 update
  • Loading branch information
ademcan authored Feb 17, 2019
2 parents b3337d6 + abfa473 commit f9a4ab4
Show file tree
Hide file tree
Showing 32 changed files with 8,972 additions and 539 deletions.
92 changes: 77 additions & 15 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import React, { Component } from 'react';
import { Button, Text, ImageBackground, ActivityIndicator, AsyncStorage, StatusBar, StyleSheet, View, Image, Linking } from 'react-native';
import { Button, Text, ImageBackground, ActivityIndicator, AsyncStorage, StatusBar, StyleSheet, View, Image, Linking, Platform } from 'react-native';
import { DrawerNavigator , StackNavigator, SwitchNavigator, DrawerItems } from 'react-navigation'; // Version can be specified in package.json
// Import the different screens
import BackupWallet from './screens/BackupWallet'
Expand All @@ -12,14 +12,19 @@ import OpenExistingWallet from './screens/OpenExistingWallet'
import SignIn from './screens/SignIn'
import CreateWalletTreeHeight from './screens/CreateWalletTreeHeight'
import CreateWalletHashFunction from './screens/CreateWalletHashFunction'
import ScanQrModal from './screens/ScanQrModal'
// import ScanQrModal from './screens/ScanQrModal'
import ConfirmTxModal from './screens/ConfirmTxModal'
import CreateAdvancedWallet from './screens/CreateAdvancedWallet'
import TxDetailsView from './screens/TxDetailsView'
import ProvideWalletPin from './screens/ProvideWalletPin'
import OpenExistingWalletModal from './screens/OpenExistingWalletModal'
import ShowQrCodeModal from './screens/ShowQrCodeModal'


// Android and Ios native modules
import {NativeModules} from 'react-native';
var IosWallet = NativeModules.refreshWallet;
var AndroidWallet = NativeModules.AndroidWallet;
// import { QRLLIB } from './node_modules/qrllib/build/web-libjsqrl.js'

// AuthLoadingScreen checks if a wallet already exists
Expand All @@ -38,13 +43,42 @@ class AuthLoadingScreen extends React.Component {
const walletCreated = await AsyncStorage.getItem('walletcreated');
// This will switch to the App screen or Auth screen and this loading
// screen will be unmounted and thrown away.
this.props.navigation.navigate(walletCreated ? 'App' : 'Auth');

// check which network to connect to: node and port
fetch('https://ademcan.net/qrlnetwork.html', {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
})
.then((response) => response.json())
.then((responseJson) => {
if (Platform.OS === 'ios'){
IosWallet.saveNodeInformation( responseJson.node, responseJson.port, (error, status)=> {
if (status == "saved"){
this.props.navigation.navigate(walletCreated ? 'App' : 'Auth');
}
});
}
else {
AndroidWallet.saveNodeInformation(responseJson.node, responseJson.port, (err) => {console.log(err);}, (status)=> {
if (status == "saved"){
this.props.navigation.navigate(walletCreated ? 'App' : 'Auth');
}
});
}
// this.setState({node: responseJson.node, port: responseJson.port })
})
.catch((error) => { console.error(error); });


};

// Render any loading content that you like here
render() {
return (
<View>
<View accessibilityLabel="AppJS">
<ActivityIndicator />
</View>
);
Expand All @@ -69,13 +103,41 @@ const CustomDrawerContentComponent = (props) => (
</View>
)


// The Stack for modals
const TxStack = StackNavigator(
{
TransactionsHistory : {
path: '/',
screen: TransactionsHistory
},
TxDetailsView : {
path: '/',
screen: TxDetailsView
},
},
{
headerMode: 'none',
}
);


// MainDrawerMenu
const MainDrawerMenu = DrawerNavigator(
{
TransactionsHistory : {
path: '/',
screen: TransactionsHistory
},
TransactionsHistory : {
path: '/',
screen: TxStack,
navigationOptions: {
drawerLabel: 'BALANCE',
drawerIcon: ({ tintColor }) => (
<Image source={require('./resources/images/transaction_history_drawer_icon_light.png')} resizeMode={Image.resizeMode.contain} style={{width:25, height:25}}/>
),
// drawerLabel: 'Settings',
// drawerIcon: ({ tintColor }) => <Icon name="cog" size={17} />,
}
},
// TransactionsHistory : TxStack,
SendReceive : {
path: '/',
screen: SendReceive
Expand All @@ -88,10 +150,10 @@ const MainDrawerMenu = DrawerNavigator(
path: '/',
screen: CreateNewWallet
},
TxDetailsView : {
path: '/',
screen: TxDetailsView
},
// TxDetailsView : {
// path: '/',
// screen: TxDetailsView
// },
},
{
// initialRouteName: 'Wallet',
Expand Down Expand Up @@ -121,9 +183,9 @@ const RootStack = StackNavigator(
ConfirmTxModal : {
screen: ConfirmTxModal
},
ScanQrModal : {
screen: ScanQrModal
},
// ScanQrModal : {
// screen: ScanQrModal
// },
ShowQrCodeModal : {
screen: ShowQrCodeModal
},
Expand Down
Binary file added __tests__.zip
Binary file not shown.
12 changes: 0 additions & 12 deletions __tests__/App.js

This file was deleted.

Binary file added __tests__/androidsampletest-1.0.0.tgz
Binary file not shown.
119 changes: 119 additions & 0 deletions __tests__/basic.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import wd from 'wd';
var TouchAction = wd.TouchAction;

import 'react-native';
import React from 'react';
import App from '../App';
import SignIn from '../screens/SignIn';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
jest.mock('react-native-camera', () => 'Camera');
jest.mock('@haskkor/react-native-pincode', () => 'PinCode');
// jest.mock('react-navigation', () => 'DrawerNavigator');
// jest.mock('react-native-camera', () => require.requireActual('../__mocks__/react-native-camera').default())

jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
const PORT = 4723;
const config = {
platformName: 'Android',
deviceName: 'Pixel_2_API_27',
automationName: "UiAutomator2",
// appPackage: 'com.theqrl',
// appActivity: 'MainActivity',
app: '/Users/abilican/Documents/projects/perso/theqrl/RNapp/theQRL/android/app/build/outputs/apk/release/qrlwallet-1.0.7.apk'
};

const driver = wd.promiseChainRemote('localhost', PORT);

// for AWS Device Farm testing
// const driver = wd.promiseChainRemote('lhttp://localhost:4723/wd/hub');


beforeAll(async () => {
await driver.init(config);
await driver.sleep(2000); // wait for app to load
})

afterAll(async () => {
try {
await driver.quit();
}
catch(err) {
console.error(err);
}
});

test('appium renders', async () => {
expect(await driver.hasElementByAccessibilityId('notthere')).toBe(false);
// expect(await driver.hasElementByAccessibilityId('testview')).toBe(true);
});

test('has correct SignIn view', async () => {
expect(await driver.hasElementByAccessibilityId('SignIn')).toBe(true);
expect(await driver.hasElementByAccessibilityId('createDefaultWalletButton')).toBe(true);
expect(await driver.hasElementByAccessibilityId('createAdvancedWalletButton')).toBe(true);
expect(await driver.hasElementByAccessibilityId('openExistingWalletButton')).toBe(true);
});

test('opens default wallet configuration when button clicked', async () => {
await driver.elementByAccessibilityId('createDefaultWalletButton').click();

});

test('has correct CompleteSetup view', async () => {
// has all the buttons
await driver.setImplicitWaitTimeout(5000);
expect(await driver.hasElementByAccessibilityId('CompleteSetup')).toBe(true);
expect(await driver.hasElementByAccessibilityId('create4digitPinButton')).toBe(true);
expect(await driver.hasElementByAccessibilityId('cancelButtonBeforePin')).toBe(true);
});

test('enter correct PIN', async () => {
await driver.setImplicitWaitTimeout(5000);
// enter test PIN
await driver.elementByAccessibilityId('create4digitPinButton').click();
// expect(await driver.hasElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[7]')).toBe(true);

// const element = await driver.hasElementByXPath('/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[7]');

let el1 = await driver.elementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[7]");
await el1.click();
await el1.click();
await el1.click();
await el1.click();

});

test('enter the same password twice', async () => {
await driver.setImplicitWaitTimeout(5000);
let el2 = await driver.elementByXPath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[7]");
await el2.click();
await el2.click();
await el2.click();
await el2.click();

});

test('show create wallet button after correct PIN', async () => {
// let pageSource = await driver.source();
// console.log(pageSource)
await driver.setImplicitWaitTimeout(10000);
expect(await driver.hasElementByAccessibilityId('createWalletButton')).toBe(true);
expect(await driver.hasElementByAccessibilityId('cancelButtonAfterPin')).toBe(true);
});

test('should create a new wallet', async () => {
// let pageSource = await driver.source();
// console.log(pageSource)
await driver.setImplicitWaitTimeout(5000);
await driver.elementByAccessibilityId('createWalletButton').click();
});

test('should show balance', async () => {
// let pageSource = await driver.source();
// console.log(pageSource)
await driver.setImplicitWaitTimeout(10000);
expect(await driver.hasElementByAccessibilityId('TransactionsHistory')).toBe(true);
});

14 changes: 14 additions & 0 deletions __tests__/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// import 'react-native';
// import React from 'react';
// import App from '../App';

// // Note: test renderer must be required after react-native.
// import renderer from 'react-test-renderer';
// // jest.mock('react-native-camera', () => require.requireActual('../__mocks__/react-native-camera').default()

// test('renders correctly', () => {
// const tree = renderer.create(
// <App />
// );
// });

21 changes: 21 additions & 0 deletions __tests__/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "androidsampletest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha test_web.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"chai": "^4.2.0",
"mocha": "^5.2.0",
"wd": "^1.11.0"
},
"bundledDependencies": [
"chai",
"mocha",
"wd"
]
}
Binary file added __tests__/test.zip
Binary file not shown.
16 changes: 15 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ android {
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0.6"
versionName "1.0.8"

testBuildType System.getProperty('testBuildType', 'debug') //this will later be used to control the test apk build type
missingDimensionStrategy "minReactNative", "minReactNative46" //read note
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

ndk {
abiFilters "armeabi-v7a", "x86"
Expand Down Expand Up @@ -298,6 +302,13 @@ dependencies {
compile project(':react-native-randombytes')
compile fileTree(dir: "libs", include: ["*.jar"])


androidTestImplementation(project(path: ":detox"))
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'


// compile "com.android.support:appcompat-v7:27.1.1"
compile "com.facebook.react:react-native:+" // From node_modules classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
implementation 'com.google.protobuf:protobuf-lite:3.0.0'
Expand All @@ -306,6 +317,9 @@ dependencies {
compile 'io.grpc:grpc-protobuf-lite:1.13.1' // CURRENT_GRPC_VERSION
compile 'io.grpc:grpc-stub:1.13.1' // CURRENT_GRPC_VERSION
compile 'javax.annotation:javax.annotation-api:1.2'

compile 'com.android.support.test:testing-support-lib:0.1'
compile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
}

// Run this once to be able to run the application with BUCK
Expand Down
24 changes: 24 additions & 0 deletions android/app/src/androidTest/java/com/theqrl/DetoxTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.theqrl;

import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.wix.detox.Detox;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {

@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);

@Test
public void runDetoxTests() throws InterruptedException {
Detox.runTests(mActivityRule);
}
}
Loading

0 comments on commit f9a4ab4

Please sign in to comment.