Skip to content

Commit 65f1006

Browse files
committed
Add tests for Content Menu
1 parent 4c8aacb commit 65f1006

File tree

13 files changed

+329
-55
lines changed

13 files changed

+329
-55
lines changed

__e2e__/TestApp/App.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

__e2e__/TestApp/__e2e__/app.spec.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { delay } from '../../utils';
33

44
describe('Main', () => {
55
beforeEach(async () => {
6+
const { client } = rndebugger;
7+
await client.execute(() => (window.confirm = () => true));
68
await device.reloadReactNative();
79
await delay(500);
810
});
@@ -12,4 +14,37 @@ describe('Main', () => {
1214
const title = await rndebugger.browserWindow.getTitle();
1315
expect(title).toBe('React Native Debugger - Connected (port 8081)');
1416
});
17+
18+
describe('Context Menu', () => {
19+
const delay200 = () => delay(200);
20+
it('should show AsyncStorage content as expected', async () => {
21+
const { client } = rndebugger;
22+
await client.execute(() => window.invokeDevMethod('showAsyncStorage')).then(delay200);
23+
let logs = await client.getRenderProcessLogs();
24+
// Print renderer process logs
25+
expect(
26+
logs.some(log => log.message.indexOf('[RNDebugger] No AsyncStorage content.') > -1)
27+
).toBeTruthy();
28+
29+
await element(by.id('navigate-async-storage'))
30+
.tap()
31+
.then(delay200);
32+
33+
await client.execute(() => window.invokeDevMethod('showAsyncStorage')).then(delay200);
34+
logs = await client.getRenderProcessLogs();
35+
expect(logs.some(log => log.message.indexOf('[object Object]') > -1)).toBeTruthy();
36+
});
37+
38+
it('should clear AsyncStorage as expected', async () => {
39+
const { client } = rndebugger;
40+
41+
await client.execute(() => window.invokeDevMethod('clearAsyncStorage')).then(delay200);
42+
await client.execute(() => window.invokeDevMethod('showAsyncStorage')).then(delay200);
43+
const logs = await client.getRenderProcessLogs();
44+
// Print renderer process logs
45+
expect(
46+
logs.some(log => log.message.indexOf('[RNDebugger] No AsyncStorage content.') > -1)
47+
).toBeTruthy();
48+
});
49+
});
1550
});

__e2e__/TestApp/android/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ android {
138138
}
139139

140140
dependencies {
141+
implementation project(':react-native-gesture-handler')
141142
implementation project(':react-native-devsettings-android')
142143
implementation fileTree(dir: "libs", include: ["*.jar"])
143144
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"

__e2e__/TestApp/android/app/src/main/java/com/testapp/MainActivity.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.testapp;
22

33
import com.facebook.react.ReactActivity;
4+
import com.facebook.react.ReactActivityDelegate;
5+
import com.facebook.react.ReactRootView;
6+
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
47

58
public class MainActivity extends ReactActivity {
69

@@ -12,4 +15,14 @@ public class MainActivity extends ReactActivity {
1215
protected String getMainComponentName() {
1316
return "TestApp";
1417
}
18+
19+
@Override
20+
protected ReactActivityDelegate createReactActivityDelegate() {
21+
return new ReactActivityDelegate(this, getMainComponentName()) {
22+
@Override
23+
protected ReactRootView createRootView() {
24+
return new RNGestureHandlerEnabledRootView(MainActivity.this);
25+
}
26+
};
27+
}
1528
}

__e2e__/TestApp/android/app/src/main/java/com/testapp/MainApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.Application;
44

55
import com.facebook.react.ReactApplication;
6+
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
67
import me.jhen.devsettings.DevSettingsPackage;
78
import com.facebook.react.ReactNativeHost;
89
import com.facebook.react.ReactPackage;
@@ -24,6 +25,7 @@ public boolean getUseDeveloperSupport() {
2425
protected List<ReactPackage> getPackages() {
2526
return Arrays.<ReactPackage>asList(
2627
new MainReactPackage(),
28+
new RNGestureHandlerPackage(),
2729
new DevSettingsPackage()
2830
);
2931
}

__e2e__/TestApp/android/settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
rootProject.name = 'TestApp'
2+
include ':react-native-gesture-handler'
3+
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
24
include ':react-native-devsettings-android'
35
project(':react-native-devsettings-android').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-devsettings-android/android')
46
include ':detox'

__e2e__/TestApp/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @lint-ignore-every XPLATJSCOPYRIGHT1
44
*/
55
import { AppRegistry, NativeModules } from 'react-native';
6-
import App from './App';
6+
import App from './js/App';
77
import { name as appName } from './app.json';
88

99
// Enforce app use debug mode

__e2e__/TestApp/ios/TestApp.xcodeproj/project.pbxproj

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
};
66
objectVersion = 46;
77
objects = {
8-
98
/* Begin PBXBuildFile section */
109
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
1110
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -40,6 +39,7 @@
4039
ADBDB9381DFEBF1600ED6528 /* libRCTBlob.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ADBDB9271DFEBF0700ED6528 /* libRCTBlob.a */; };
4140
ED297163215061F000B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED297162215061F000B7C4FE /* JavaScriptCore.framework */; };
4241
ED2971652150620600B7C4FE /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = ED2971642150620600B7C4FE /* JavaScriptCore.framework */; };
42+
9016FE32117E4E6BB2BF21E3 /* libRNGestureHandler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E0E392F9AB71456DA72217D6 /* libRNGestureHandler.a */; };
4343
/* End PBXBuildFile section */
4444

4545
/* Begin PBXContainerItemProxy section */
@@ -347,6 +347,8 @@
347347
ADBDB91F1DFEBF0600ED6528 /* RCTBlob.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTBlob.xcodeproj; path = "../node_modules/react-native/Libraries/Blob/RCTBlob.xcodeproj"; sourceTree = "<group>"; };
348348
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
349349
ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
350+
275A76F1C5F248B19E1D2AF5 /* RNGestureHandler.xcodeproj */ = {isa = PBXFileReference; name = "RNGestureHandler.xcodeproj"; path = "../node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
351+
E0E392F9AB71456DA72217D6 /* libRNGestureHandler.a */ = {isa = PBXFileReference; name = "libRNGestureHandler.a"; path = "libRNGestureHandler.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
350352
/* End PBXFileReference section */
351353

352354
/* Begin PBXFrameworksBuildPhase section */
@@ -375,6 +377,7 @@
375377
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
376378
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
377379
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
380+
9016FE32117E4E6BB2BF21E3 /* libRNGestureHandler.a in Frameworks */,
378381
);
379382
runOnlyForDeploymentPostprocessing = 0;
380383
};
@@ -564,6 +567,7 @@
564567
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */,
565568
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
566569
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
570+
275A76F1C5F248B19E1D2AF5 /* RNGestureHandler.xcodeproj */,
567571
);
568572
name = Libraries;
569573
sourceTree = "<group>";
@@ -692,7 +696,7 @@
692696
83CBB9F71A601CBA00E9B192 /* Project object */ = {
693697
isa = PBXProject;
694698
attributes = {
695-
LastUpgradeCheck = 0940;
699+
LastUpgradeCheck = 940;
696700
ORGANIZATIONNAME = Facebook;
697701
TargetAttributes = {
698702
00E356ED1AD99517003FC87E = {
@@ -1189,6 +1193,14 @@
11891193
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
11901194
PRODUCT_NAME = "$(TARGET_NAME)";
11911195
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestApp.app/TestApp";
1196+
LIBRARY_SEARCH_PATHS = (
1197+
"$(inherited)",
1198+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1199+
);
1200+
HEADER_SEARCH_PATHS = (
1201+
"$(inherited)",
1202+
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
1203+
);
11921204
};
11931205
name = Debug;
11941206
};
@@ -1207,6 +1219,14 @@
12071219
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
12081220
PRODUCT_NAME = "$(TARGET_NAME)";
12091221
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestApp.app/TestApp";
1222+
LIBRARY_SEARCH_PATHS = (
1223+
"$(inherited)",
1224+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1225+
);
1226+
HEADER_SEARCH_PATHS = (
1227+
"$(inherited)",
1228+
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
1229+
);
12101230
};
12111231
name = Release;
12121232
};
@@ -1226,6 +1246,10 @@
12261246
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
12271247
PRODUCT_NAME = TestApp;
12281248
VERSIONING_SYSTEM = "apple-generic";
1249+
HEADER_SEARCH_PATHS = (
1250+
"$(inherited)",
1251+
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
1252+
);
12291253
};
12301254
name = Debug;
12311255
};
@@ -1244,6 +1268,10 @@
12441268
PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
12451269
PRODUCT_NAME = TestApp;
12461270
VERSIONING_SYSTEM = "apple-generic";
1271+
HEADER_SEARCH_PATHS = (
1272+
"$(inherited)",
1273+
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
1274+
);
12471275
};
12481276
name = Release;
12491277
};
@@ -1270,6 +1298,14 @@
12701298
SDKROOT = appletvos;
12711299
TARGETED_DEVICE_FAMILY = 3;
12721300
TVOS_DEPLOYMENT_TARGET = 9.2;
1301+
LIBRARY_SEARCH_PATHS = (
1302+
"$(inherited)",
1303+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1304+
);
1305+
HEADER_SEARCH_PATHS = (
1306+
"$(inherited)",
1307+
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
1308+
);
12731309
};
12741310
name = Debug;
12751311
};
@@ -1296,6 +1332,14 @@
12961332
SDKROOT = appletvos;
12971333
TARGETED_DEVICE_FAMILY = 3;
12981334
TVOS_DEPLOYMENT_TARGET = 9.2;
1335+
LIBRARY_SEARCH_PATHS = (
1336+
"$(inherited)",
1337+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1338+
);
1339+
HEADER_SEARCH_PATHS = (
1340+
"$(inherited)",
1341+
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
1342+
);
12991343
};
13001344
name = Release;
13011345
};
@@ -1321,6 +1365,14 @@
13211365
SDKROOT = appletvos;
13221366
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestApp-tvOS.app/TestApp-tvOS";
13231367
TVOS_DEPLOYMENT_TARGET = 10.1;
1368+
LIBRARY_SEARCH_PATHS = (
1369+
"$(inherited)",
1370+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1371+
);
1372+
HEADER_SEARCH_PATHS = (
1373+
"$(inherited)",
1374+
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
1375+
);
13241376
};
13251377
name = Debug;
13261378
};
@@ -1346,6 +1398,14 @@
13461398
SDKROOT = appletvos;
13471399
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/TestApp-tvOS.app/TestApp-tvOS";
13481400
TVOS_DEPLOYMENT_TARGET = 10.1;
1401+
LIBRARY_SEARCH_PATHS = (
1402+
"$(inherited)",
1403+
"\"$(SRCROOT)/$(TARGET_NAME)\"",
1404+
);
1405+
HEADER_SEARCH_PATHS = (
1406+
"$(inherited)",
1407+
"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**",
1408+
);
13491409
};
13501410
name = Release;
13511411
};

__e2e__/TestApp/js/App.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createStackNavigator, createAppContainer } from 'react-navigation';
2+
import Home from './Home';
3+
import TestAsyncStorage from './containers/TestAsyncStorage';
4+
5+
const AppNavigator = createStackNavigator(
6+
{
7+
Home: { screen: Home },
8+
TestAsyncStorage: { screen: TestAsyncStorage },
9+
},
10+
{
11+
initialRouteName: 'Home',
12+
headerMode: 'none',
13+
}
14+
);
15+
16+
export default createAppContainer(AppNavigator);

__e2e__/TestApp/js/Home.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { StyleSheet, View, Button } from 'react-native';
4+
5+
const styles = StyleSheet.create({
6+
container: {
7+
flex: 1,
8+
backgroundColor: '#333',
9+
justifyContent: 'center',
10+
alignItems: 'center',
11+
},
12+
});
13+
14+
export default class Home extends React.Component {
15+
static propTypes = {
16+
navigation: PropTypes.shape({
17+
navigate: PropTypes.func.isRequired,
18+
}).isRequired,
19+
};
20+
render() {
21+
const { navigation } = this.props;
22+
return (
23+
<View testID="home" style={styles.container}>
24+
<Button
25+
testID="navigate-async-storage"
26+
title="Test Async Storage"
27+
onPress={() => navigation.navigate('TestAsyncStorage')}
28+
/>
29+
</View>
30+
);
31+
}
32+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import { StyleSheet, View, AsyncStorage } from 'react-native';
3+
4+
const styles = StyleSheet.create({
5+
container: {
6+
flex: 1,
7+
backgroundColor: '#333',
8+
justifyContent: 'center',
9+
alignItems: 'center',
10+
},
11+
});
12+
13+
export default class TestAsyncStorage extends React.Component {
14+
componentDidMount() {
15+
AsyncStorage.setItem('some', 'key');
16+
}
17+
render() {
18+
return <View style={styles.container} />;
19+
}
20+
}

0 commit comments

Comments
 (0)