mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-22 04:24:09 +00:00
commit
e1f69ed005
2
.gitignore
vendored
2
.gitignore
vendored
@ -55,3 +55,5 @@ tests/realm-object-server/
|
||||
packager_out.txt
|
||||
build.log.*
|
||||
realm-object-server/
|
||||
tests/react-test-app/ios/out.txt
|
||||
*.iml
|
||||
|
@ -126,6 +126,7 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':react-native-exit-app-no-history')
|
||||
compile fileTree(dir: "libs", include: ["*.jar"])
|
||||
compile "com.android.support:appcompat-v7:23.0.1"
|
||||
compile "com.facebook.react:react-native:+" // From node_modules
|
||||
|
@ -4,6 +4,7 @@ import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.react.ReactApplication;
|
||||
import com.github.wumke.RNExitApp.RNExitAppPackage;
|
||||
import com.facebook.react.ReactInstanceManager;
|
||||
import com.facebook.react.ReactNativeHost;
|
||||
import com.facebook.react.ReactPackage;
|
||||
@ -27,6 +28,7 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
protected List<ReactPackage> getPackages() {
|
||||
return Arrays.<ReactPackage>asList(
|
||||
new MainReactPackage(),
|
||||
new RNExitAppPackage(),
|
||||
new RealmReactPackage()
|
||||
);
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
rootProject.name = 'ReactExample'
|
||||
include ':react-native-exit-app-no-history'
|
||||
project(':react-native-exit-app-no-history').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exit-app-no-history/android')
|
||||
|
||||
include ':app'
|
||||
|
||||
|
63
examples/ReactExample/components/items-screen.js
Normal file
63
examples/ReactExample/components/items-screen.js
Normal file
@ -0,0 +1,63 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2017 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {
|
||||
Platform,
|
||||
StatusBar,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} from 'react-native';
|
||||
|
||||
import TodoItem from './todo-item';
|
||||
import TodoListView from './todo-listview';
|
||||
import TodoItemsView from './todo-itemsview';
|
||||
import TodoListItem from './todo-list-item';
|
||||
import realm from './realm';
|
||||
import styles from './styles';
|
||||
|
||||
import { StackNavigator } from 'react-navigation';
|
||||
|
||||
export default class ItemsScreen extends React.Component {
|
||||
static navigationOptions = {
|
||||
title: 'Current list',
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
if (Platform.OS == 'ios') {
|
||||
StatusBar.setBarStyle('light-content');
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
let properties = {
|
||||
}
|
||||
|
||||
return <TodoItemsView items={this.props.navigation.state.params.items} {...properties} />;
|
||||
}
|
||||
}
|
1
examples/ReactExample/components/params.json
Normal file
1
examples/ReactExample/components/params.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
@ -19,14 +19,13 @@
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
Navigator,
|
||||
Platform,
|
||||
StyleSheet
|
||||
} from 'react-native';
|
||||
|
||||
const { NavBarHeight, TotalNavHeight } = Navigator.NavigationBar.Styles.General;
|
||||
const iOS = (Platform.OS == 'ios');
|
||||
|
||||
|
||||
export default StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
@ -43,7 +42,7 @@ export default StyleSheet.create({
|
||||
navBarView: {
|
||||
alignItems: 'center',
|
||||
flexDirection: 'row',
|
||||
height: NavBarHeight,
|
||||
height: 20,
|
||||
},
|
||||
navBarLeftArrow: {
|
||||
color: '#fff',
|
||||
@ -66,7 +65,7 @@ export default StyleSheet.create({
|
||||
fontWeight: '500',
|
||||
},
|
||||
navScene: {
|
||||
top: TotalNavHeight,
|
||||
top: 20,
|
||||
},
|
||||
listItem: {
|
||||
borderColor: '#c8c7cc',
|
||||
|
@ -21,7 +21,6 @@
|
||||
import React from 'react';
|
||||
|
||||
import {
|
||||
Navigator,
|
||||
Platform,
|
||||
StatusBar,
|
||||
Text,
|
||||
@ -31,10 +30,21 @@ import {
|
||||
|
||||
import TodoItem from './todo-item';
|
||||
import TodoListView from './todo-listview';
|
||||
import TodoListItem from './todo-list-item';
|
||||
import ItemsScreen from './items-screen'
|
||||
import realm from './realm';
|
||||
import styles from './styles';
|
||||
|
||||
export default class TodoApp extends React.Component {
|
||||
import { StackNavigator } from 'react-navigation';
|
||||
import RNExitApp from 'react-native-exit-app-no-history';
|
||||
|
||||
const params = require("./params.json");
|
||||
|
||||
class HomeScreen extends React.Component {
|
||||
static navigationOptions = {
|
||||
title: 'Todo Lists',
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
@ -42,17 +52,20 @@ export default class TodoApp extends React.Component {
|
||||
this.todoLists = realm.objects('TodoList').sorted('creationDate');
|
||||
if (this.todoLists.length < 1) {
|
||||
realm.write(() => {
|
||||
realm.create('TodoList', {name: 'Todo List', creationDate: new Date()});
|
||||
realm.create('TodoList', { name: 'Todo List', creationDate: new Date() });
|
||||
});
|
||||
}
|
||||
this.todoLists.addListener((name, changes) => {
|
||||
console.log("changed: " + JSON.stringify(changes));
|
||||
if (params) {
|
||||
console.error("params.json indicates a test run. Exiting application");
|
||||
RNExitApp.exitApp();
|
||||
}
|
||||
});
|
||||
console.log("registered listener");
|
||||
|
||||
|
||||
// Bind all the methods that we will be passing as props.
|
||||
this.renderScene = this.renderScene.bind(this);
|
||||
this._addNewTodoList = this._addNewTodoList.bind(this);
|
||||
this._onPressTodoList = this._onPressTodoList.bind(this);
|
||||
|
||||
@ -73,37 +86,17 @@ export default class TodoApp extends React.Component {
|
||||
render() {
|
||||
let objects = realm.objects('Todo');
|
||||
let extraItems = [
|
||||
{name: 'Complete', items: objects.filtered('done = true')},
|
||||
{name: 'Incomplete', items: objects.filtered('done = false')},
|
||||
{ name: 'Complete', items: objects.filtered('done = true') },
|
||||
{ name: 'Incomplete', items: objects.filtered('done = false') },
|
||||
];
|
||||
|
||||
let route = {
|
||||
title: 'My Todo Lists',
|
||||
component: TodoListView,
|
||||
passProps: {
|
||||
ref: 'listView',
|
||||
extraItems: extraItems,
|
||||
onPressItem: this._onPressTodoList,
|
||||
},
|
||||
backButtonTitle: 'Lists',
|
||||
rightButtonTitle: 'Add',
|
||||
onRightButtonPress: this._addNewTodoList,
|
||||
};
|
||||
let properties = {
|
||||
ref: 'listView',
|
||||
extraItems: extraItems,
|
||||
onPressItem: this._onPressTodoList,
|
||||
}
|
||||
|
||||
let navigationBar = (
|
||||
<Navigator.NavigationBar routeMapper={RouteMapper} style={styles.navBar} />
|
||||
);
|
||||
|
||||
return (
|
||||
<Navigator
|
||||
ref="nav"
|
||||
initialRoute={route}
|
||||
navigationBar={navigationBar}
|
||||
renderScene={this.renderScene}
|
||||
sceneStyle={styles.navScene}
|
||||
style={styles.navigator}
|
||||
/>
|
||||
);
|
||||
return <TodoListView items={this.todoLists} {...properties} />;
|
||||
}
|
||||
|
||||
renderScene(route) {
|
||||
@ -118,7 +111,7 @@ export default class TodoApp extends React.Component {
|
||||
}
|
||||
|
||||
realm.write(() => {
|
||||
items.push({text: ''});
|
||||
items.push({ text: '' });
|
||||
});
|
||||
|
||||
this._setEditingRow(items.length - 1);
|
||||
@ -131,34 +124,17 @@ export default class TodoApp extends React.Component {
|
||||
}
|
||||
|
||||
realm.write(() => {
|
||||
realm.create('TodoList', {name: '', creationDate: new Date()});
|
||||
realm.create('TodoList', { name: '', creationDate: new Date() });
|
||||
});
|
||||
|
||||
this._setEditingRow(items.length - 1);
|
||||
}
|
||||
|
||||
_onPressTodoList(list) {
|
||||
const { navigate } = this.props.navigation;
|
||||
let items = list.items;
|
||||
|
||||
let route = {
|
||||
title: list.name,
|
||||
component: TodoListView,
|
||||
passProps: {
|
||||
ref: 'listItemView',
|
||||
items: items,
|
||||
rowClass: TodoItem,
|
||||
},
|
||||
};
|
||||
|
||||
// Check if the items are mutable (i.e. List rather than Results).
|
||||
if (items.push) {
|
||||
Object.assign(route, {
|
||||
rightButtonTitle: 'Add',
|
||||
onRightButtonPress: () => this._addNewTodoItem(list),
|
||||
});
|
||||
}
|
||||
|
||||
this.refs.nav.push(route);
|
||||
navigate('ItemsScreen', { items: items })
|
||||
}
|
||||
|
||||
_shouldAddNewItem(items) {
|
||||
@ -173,53 +149,14 @@ export default class TodoApp extends React.Component {
|
||||
let listView = this.currentListView;
|
||||
|
||||
// Update the state on the currently displayed TodoList to edit this new item.
|
||||
listView.setState({editingRow: rowIndex});
|
||||
listView.setState({ editingRow: rowIndex });
|
||||
listView.updateDataSource();
|
||||
}
|
||||
}
|
||||
|
||||
const RouteMapper = {
|
||||
LeftButton(route, navigator, index, navState) {
|
||||
if (index == 0) {
|
||||
return null;
|
||||
}
|
||||
const SimpleApp = StackNavigator({
|
||||
Home: { screen: HomeScreen },
|
||||
ItemsScreen: { screen: ItemsScreen }
|
||||
});
|
||||
|
||||
let prevRoute = navState.routeStack[index - 1];
|
||||
return (
|
||||
<TouchableOpacity onPress={() => navigator.pop()}>
|
||||
<View style={[styles.navBarView, styles.navBarLeftButton]}>
|
||||
<Text style={styles.navBarLeftArrow}>‹</Text>
|
||||
<Text style={styles.navBarText}>
|
||||
{prevRoute.backButtonTitle || prevRoute.title || 'Back'}
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
},
|
||||
|
||||
RightButton(route) {
|
||||
if (!route.rightButtonTitle) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<TouchableOpacity onPress={route.onRightButtonPress}>
|
||||
<View style={[styles.navBarView, styles.navBarRightButton]}>
|
||||
<Text style={styles.navBarText}>
|
||||
{route.rightButtonTitle}
|
||||
</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
},
|
||||
|
||||
Title(route) {
|
||||
return (
|
||||
<View style={styles.navBarView}>
|
||||
<Text style={[styles.navBarText, styles.navBarTitleText]}>
|
||||
{route.title}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
},
|
||||
};
|
||||
export default SimpleApp;
|
165
examples/ReactExample/components/todo-itemsview.js
Normal file
165
examples/ReactExample/components/todo-itemsview.js
Normal file
@ -0,0 +1,165 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
'use strict';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import {
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
|
||||
import { ListView } from 'realm/react-native';
|
||||
import TodoItem from './todo-item';
|
||||
import realm from './realm';
|
||||
import styles from './styles';
|
||||
|
||||
export default class TodoItemsView extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
let dataSource = new ListView.DataSource({
|
||||
rowHasChanged(a, b) {
|
||||
// Always re-render TodoList items.
|
||||
return a.done !== b.done || a.text !== b.text || a.items || b.items;
|
||||
}
|
||||
});
|
||||
|
||||
this.state = {
|
||||
dataSource: this._cloneDataSource(dataSource, props),
|
||||
};
|
||||
|
||||
this.renderRow = this.renderRow.bind(this);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(props) {
|
||||
this.updateDataSource(props);
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
let items = this.props.items;
|
||||
let editingRow = this.state.editingRow;
|
||||
|
||||
for (let i = items.length; i--;) {
|
||||
if (i == editingRow) {
|
||||
continue;
|
||||
}
|
||||
if (this._deleteItemIfEmpty(items[i]) && i < editingRow) {
|
||||
editingRow--;
|
||||
}
|
||||
}
|
||||
|
||||
if (editingRow != this.state.editingRow) {
|
||||
this.setState({editingRow});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<ListView dataSource={this.state.dataSource} renderRow={this.renderRow} enableEmptySections/>
|
||||
<Text style={styles.instructions}>
|
||||
Press Cmd+R to reload,{'\n'}
|
||||
Cmd+D for dev menu
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
renderRow(item, sectionIndex, rowIndex) {
|
||||
let RowClass;
|
||||
let editing = false;
|
||||
|
||||
return (
|
||||
<TodoItem
|
||||
item={item}
|
||||
editing={editing}
|
||||
onPress={() => this._onPressRow(item, sectionIndex, rowIndex)}
|
||||
onPressDelete={() => this._onPressDeleteRow(item)}
|
||||
onEndEditing={() => this._onEndEditingRow(item, rowIndex)} />
|
||||
);
|
||||
}
|
||||
|
||||
updateDataSource(props=this.props) {
|
||||
this.setState({
|
||||
dataSource: this._cloneDataSource(this.state.dataSource, props),
|
||||
});
|
||||
}
|
||||
|
||||
_cloneDataSource(dataSource, props) {
|
||||
let items = props.items;
|
||||
let extraItems = props.extraItems;
|
||||
let sections = [items ? items.snapshot() : []];
|
||||
|
||||
if (extraItems && extraItems.length) {
|
||||
sections.push(extraItems);
|
||||
}
|
||||
|
||||
return dataSource.cloneWithRowsAndSections(sections);
|
||||
}
|
||||
|
||||
_onPressRow(item, sectionIndex, rowIndex) {
|
||||
let onPressItem = this.props.onPressItem;
|
||||
if (onPressItem) {
|
||||
onPressItem(item);
|
||||
return;
|
||||
}
|
||||
|
||||
// If no handler was provided, then default to editing the row.
|
||||
if (sectionIndex == 0) {
|
||||
this.setState({editingRow: rowIndex});
|
||||
}
|
||||
}
|
||||
|
||||
_onPressDeleteRow(item) {
|
||||
this._deleteItem(item);
|
||||
this.updateDataSource();
|
||||
}
|
||||
|
||||
_onEndEditingRow(item, rowIndex) {
|
||||
if (this._deleteItemIfEmpty(item)) {
|
||||
this.updateDataSource();
|
||||
}
|
||||
if (this.state.editingRow == rowIndex) {
|
||||
this.setState({editingRow: null});
|
||||
}
|
||||
}
|
||||
|
||||
_deleteItem(item) {
|
||||
let items = item.items;
|
||||
|
||||
realm.write(() => {
|
||||
// If the item is a TodoList, then delete all of its items.
|
||||
if (items && items.length) {
|
||||
realm.delete(items);
|
||||
}
|
||||
|
||||
realm.delete(item);
|
||||
});
|
||||
}
|
||||
|
||||
_deleteItemIfEmpty(item) {
|
||||
// The item could be a TodoList or a Todo.
|
||||
if (!item.name && !item.text) {
|
||||
this._deleteItem(item);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -42,7 +42,12 @@ export default class TodoListItem extends React.Component {
|
||||
|
||||
get done() {
|
||||
let items = this.props.item.items;
|
||||
return items.length > 0 && items.every((item) => item.done);
|
||||
if (items) {
|
||||
return items.length > 0 && items.every((item) => item.done);
|
||||
}
|
||||
else {
|
||||
return this.props.item.done;
|
||||
}
|
||||
}
|
||||
|
||||
get text() {
|
||||
|
@ -73,7 +73,7 @@ export default class TodoListView extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<ListView dataSource={this.state.dataSource} renderRow={this.renderRow} />
|
||||
<ListView dataSource={this.state.dataSource} renderRow={this.renderRow} enableEmptySections/>
|
||||
<Text style={styles.instructions}>
|
||||
Press Cmd+R to reload,{'\n'}
|
||||
Cmd+D for dev menu
|
||||
|
@ -5,7 +5,6 @@
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
|
||||
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
|
||||
@ -28,6 +27,7 @@
|
||||
8573DE511E23DDA700914396 /* ReactExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8573DE501E23DDA700914396 /* ReactExampleTests.m */; };
|
||||
B06E5AD59A024665BD24C8C7 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C4594A7EF1647D68ADF0ED0 /* libz.tbd */; };
|
||||
EF9CDEC26BA64438B1A9F856 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = C202449017C94855B351AE73 /* libc++.tbd */; };
|
||||
F5A48833F58A45B2A8E9F550 /* libRNExitApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F25C98ECB41447FB9BA11E19 /* libRNExitApp.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@ -253,6 +253,8 @@
|
||||
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
|
||||
8573DE501E23DDA700914396 /* ReactExampleTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ReactExampleTests.m; sourceTree = "<group>"; };
|
||||
C202449017C94855B351AE73 /* libc++.tbd */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
|
||||
A07E5AD22EFC47D594326945 /* RNExitApp.xcodeproj */ = {isa = PBXFileReference; name = "RNExitApp.xcodeproj"; path = "../node_modules/react-native-exit-app-no-history/ios/RNExitApp.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
|
||||
F25C98ECB41447FB9BA11E19 /* libRNExitApp.a */ = {isa = PBXFileReference; name = "libRNExitApp.a"; path = "libRNExitApp.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -282,6 +284,7 @@
|
||||
146834051AC3E58100842450 /* libReact.a in Frameworks */,
|
||||
70C063557D0D491D8F4D348F /* libRealmReact.a in Frameworks */,
|
||||
B06E5AD59A024665BD24C8C7 /* libz.tbd in Frameworks */,
|
||||
F5A48833F58A45B2A8E9F550 /* libRNExitApp.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -447,6 +450,7 @@
|
||||
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
|
||||
146833FF1AC3E56700842450 /* React.xcodeproj */,
|
||||
73AD103601A44EB291AC2117 /* RealmReact.xcodeproj */,
|
||||
A07E5AD22EFC47D594326945 /* RNExitApp.xcodeproj */,
|
||||
);
|
||||
name = Libraries;
|
||||
sourceTree = "<group>";
|
||||
@ -832,7 +836,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
|
||||
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
@ -891,6 +895,7 @@
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ReactExample.app/ReactExample";
|
||||
@ -908,6 +913,7 @@
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ReactExample.app/ReactExample";
|
||||
|
@ -1,24 +1,26 @@
|
||||
{
|
||||
"name": "ReactExample",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node node_modules/react-native/local-cli/cli.js start",
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "~15.4.0-rc.4",
|
||||
"react-native": "0.40.0",
|
||||
"realm": "file:../.."
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-jest": "18.0.0",
|
||||
"babel-preset-react-native": "1.9.1",
|
||||
"jest": "18.1.0",
|
||||
"react-test-renderer": "~15.4.0-rc.4",
|
||||
"invariant": "^2.2.2"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "react-native"
|
||||
}
|
||||
}
|
||||
"name": "ReactExample",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "node node_modules/react-native/local-cli/cli.js start",
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "16.0.0",
|
||||
"react-native": "0.50.4",
|
||||
"react-navigation": "^1.0.0-beta.21",
|
||||
"react-native-exit-app-no-history": "^1.0.2",
|
||||
"realm": "file:../.."
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-jest": "18.0.0",
|
||||
"babel-preset-react-native": "4.0.0",
|
||||
"invariant": "^2.2.2",
|
||||
"jest": "18.1.0",
|
||||
"react-test-renderer": "^16.2.0"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "react-native"
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +91,8 @@
|
||||
"request": "^2.78.0",
|
||||
"stream-counter": "^1.0.0",
|
||||
"sync-request": "^3.0.1",
|
||||
"url-parse": "^1.1.7"
|
||||
"url-parse": "^1.1.7",
|
||||
"lzma-native": "^3.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^6.0.4",
|
||||
|
@ -9,15 +9,11 @@ set -eo pipefail
|
||||
#use existing server if same version
|
||||
if [ -f node_modules/realm-object-server/package.json ]; then
|
||||
if grep -q "\"version\": \"$REALM_OBJECT_SERVER_VERSION\"" node_modules/realm-object-server/package.json; then
|
||||
# echo -e "yes\n" | object-server-for-testing/reset-server-realms.command
|
||||
rm -rf realm-object-server-data
|
||||
rm -rf realm-object-server
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Uninstalling old version of realm-object-server"
|
||||
npm uninstall realm-object-server
|
||||
|
||||
echo "Installing realm-object-server version: " $REALM_OBJECT_SERVER_VERSION
|
||||
npm install realm-object-server@$REALM_OBJECT_SERVER_VERSION
|
9
scripts/find-ios-runtime.rb
Normal file
9
scripts/find-ios-runtime.rb
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'json'
|
||||
|
||||
runtime = JSON.parse(%x{xcrun simctl list devices --json})['runtimes']
|
||||
.select{|x| (x['identifier'].include? 'com.apple.CoreSimulator.SimRuntime.iOS') &&
|
||||
(x['availability'] == "(available)")}[0]["identifier"]
|
||||
|
||||
puts runtime
|
2
scripts/react-tests-android.js
vendored
2
scripts/react-tests-android.js
vendored
@ -64,6 +64,6 @@ shell.exec("adb shell am start -n io.realm.react.testapp/.MainActivity");
|
||||
|
||||
shell.popd();
|
||||
|
||||
shell.exec("adb shell \"logcat -c && logcat | grep -m 1 __REALM_REACT_ANDROID_TESTS_COMPLETED__\"");
|
||||
shell.exec("adb shell \"logcat -c && logcat | grep -m 1 __REALM_JS_TESTS_COMPLETED__\"");
|
||||
|
||||
shell.exec("adb pull /sdcard/tests.xml");
|
182
scripts/test.sh
182
scripts/test.sh
@ -23,6 +23,8 @@ if [ -n "${JENKINS_HOME}" ]; then
|
||||
CI_RUN=true
|
||||
fi
|
||||
|
||||
SIM_DEVICE_NAME=realm-js-test
|
||||
|
||||
# Start current working directory at the root of the project.
|
||||
cd "$SRCROOT"
|
||||
|
||||
@ -64,7 +66,7 @@ stop_server() {
|
||||
echo stopping server
|
||||
if [[ ${SERVER_PID} -gt 0 ]] ; then
|
||||
echo server is running. killing it
|
||||
kill -9 ${SERVER_PID} || true
|
||||
kill -9 ${SERVER_PID} >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
@ -75,6 +77,9 @@ cleanup() {
|
||||
# Kill started object server
|
||||
stop_server || true
|
||||
|
||||
echo "shutting down running simulators"
|
||||
shutdown_ios_simulator >/dev/null 2>&1
|
||||
|
||||
# Quit Simulator.app to give it a chance to go down gracefully
|
||||
if $startedSimulator; then
|
||||
osascript -e 'tell app "Simulator" to quit without saving' || true
|
||||
@ -97,7 +102,11 @@ cleanup() {
|
||||
fi
|
||||
}
|
||||
|
||||
open_chrome() {
|
||||
open_chrome() {
|
||||
if [ $CONFIGURATION == 'Release' ]; then
|
||||
return;
|
||||
fi
|
||||
|
||||
local dir
|
||||
for dir in "$HOME/Applications" "/Applications"; do
|
||||
if [ -d "$dir/Google Chrome.app" ]; then
|
||||
@ -109,10 +118,10 @@ open_chrome() {
|
||||
|
||||
start_packager() {
|
||||
watchman watch-del-all || true
|
||||
./node_modules/react-native/packager/packager.sh | tee "$PACKAGER_OUT" &
|
||||
./node_modules/react-native/scripts/packager.sh | tee "$PACKAGER_OUT" &
|
||||
|
||||
while :; do
|
||||
if grep -Fxq "React packager ready." "$PACKAGER_OUT"; then
|
||||
if grep -Fxq "Metro Bundler ready." "$PACKAGER_OUT"; then
|
||||
break
|
||||
else
|
||||
echo "Waiting for packager."
|
||||
@ -124,126 +133,67 @@ start_packager() {
|
||||
xctest() {
|
||||
setup_ios_simulator
|
||||
|
||||
# - Wait until the simulator is fully booted by waiting for it to launch SpringBoard
|
||||
printf "Waiting for springboard to ensure device is ready..."
|
||||
xcrun simctl launch "$IOS_SIM_DEVICE" com.apple.springboard 1>/dev/null 2>/dev/null || true
|
||||
echo " done"
|
||||
|
||||
# - Run the build and test
|
||||
xcrun xcodebuild -scheme "$1" -configuration "$CONFIGURATION" -sdk iphonesimulator -destination id="$IOS_SIM_DEVICE" build || {
|
||||
echo "Building application"
|
||||
xcrun xcodebuild -scheme "$1" -configuration "$CONFIGURATION" -sdk iphonesimulator -destination id="${IOS_SIM_DEVICE_ID}" -derivedDataPath ./build build || {
|
||||
EXITCODE=$?
|
||||
echo "*** Failure (exit code $EXITCODE). ***"
|
||||
exit $EXITCODE
|
||||
}
|
||||
if [ -n "$XCPRETTY" ]; then
|
||||
log_temp=$(mktemp build.log.XXXXXX)
|
||||
if [ -e "$log_temp" ]; then
|
||||
rm "$log_temp"
|
||||
fi
|
||||
xcrun xcodebuild -scheme "$1" -configuration "$CONFIGURATION" -sdk iphonesimulator -destination name="iPhone 5s" test 2>&1 | tee "$log_temp" | "$XCPRETTY" -c --no-utf --report junit --output build/reports/junit.xml || {
|
||||
EXITCODE=$?
|
||||
printf "*** Xcode Failure (exit code %s). The full xcode log follows: ***\n\n" "$EXITCODE"
|
||||
cat "$log_temp"
|
||||
printf "\n\n*** End Xcode Failure ***\n"
|
||||
exit $EXITCODE
|
||||
}
|
||||
rm "$log_temp"
|
||||
|
||||
echo "Installing application on ${SIM_DEVICE_NAME}"
|
||||
echo "Application Path" $(pwd)/build/Build/Products/$CONFIGURATION-iphonesimulator/$1.app
|
||||
xcrun simctl install ${SIM_DEVICE_NAME} $(pwd)/build/Build/Products/$CONFIGURATION-iphonesimulator/$1.app
|
||||
|
||||
|
||||
echo "Launching application. (output is in $(pwd)/build/out.txt)"
|
||||
xcrun simctl launch --console ${SIM_DEVICE_NAME} io.realm.$1 | tee $(pwd)/build/out.txt
|
||||
|
||||
echo "Shuttting down ${SIM_DEVICE_NAME} simulator. (device is not deleted. you can use it to debug the app)"
|
||||
shutdown_ios_simulator
|
||||
|
||||
check_test_results $1
|
||||
}
|
||||
|
||||
check_test_results() {
|
||||
echo "Checking tests results"
|
||||
if grep -q "REALM_FAILING_TESTS" $(pwd)/build/out.txt; then
|
||||
echo "*** REALM JS TESTS FAILED. See tests results above ***"
|
||||
exit 20
|
||||
else
|
||||
xcrun xcodebuild -scheme "$1" -configuration "$CONFIGURATION" -sdk iphonesimulator -destination id="$IOS_SIM_DEVICE" test || {
|
||||
EXITCODE=$?
|
||||
echo "*** Failure (exit code $EXITCODE). ***"
|
||||
exit $EXITCODE
|
||||
}
|
||||
echo "*** $1 SUCCESS ***"
|
||||
fi
|
||||
}
|
||||
|
||||
setup_ios_simulator() {
|
||||
# - Ensure one version of xcode is chosen by all tools
|
||||
if [[ -z "$DEVELOPER_DIR" ]]; then
|
||||
DEV_DIR="$(xcode-select -p)"
|
||||
export DEVELOPER_DIR=$DEV_DIR
|
||||
fi
|
||||
setup_ios_simulator() {
|
||||
#try deleting old simulator with same name.
|
||||
echo "Preparing to create a new simulator"
|
||||
delete_ios_simulator >/dev/null 2>&1
|
||||
|
||||
# -- Ensure that the simulator is ready
|
||||
#parse devices
|
||||
IOS_RUNTIME=$(xcrun simctl list runtimes | grep -m1 -o 'com.apple.CoreSimulator.SimRuntime.iOS.*' | sed 's/[()]//g')
|
||||
echo using iOS Runtime ${IOS_RUNTIME} to create new simulator ${SIM_DEVICE_NAME}
|
||||
|
||||
if [ $CI_RUN == true ]; then
|
||||
# - Kill the Simulator to ensure we are running the correct one, only when running in CI
|
||||
echo "Resetting simulator using toolchain from: $DEVELOPER_DIR"
|
||||
#create new test simulator
|
||||
IOS_SIM_DEVICE_ID=$(xcrun simctl create ${SIM_DEVICE_NAME} com.apple.CoreSimulator.SimDeviceType.iPhone-SE ${IOS_RUNTIME})
|
||||
#boot new test simulator
|
||||
xcrun simctl boot ${SIM_DEVICE_NAME}
|
||||
}
|
||||
|
||||
# Quit Simulator.app to give it a chance to go down gracefully
|
||||
local deadline=$((SECONDS+5))
|
||||
while pgrep -qx Simulator && [ $SECONDS -lt $deadline ]; do
|
||||
osascript -e 'tell app "Simulator" to quit without saving' || true
|
||||
sleep 0.25 # otherwise the pkill following will get it too early
|
||||
done
|
||||
shutdown_ios_simulator() {
|
||||
#shutdown test simulator
|
||||
xcrun simctl shutdown ${SIM_DEVICE_NAME} || true
|
||||
}
|
||||
|
||||
# stop CoreSimulatorService
|
||||
launchctl remove com.apple.CoreSimulator.CoreSimulatorService 2>/dev/null || true
|
||||
sleep 0.25 # launchtl can take a small moment to kill services
|
||||
delete_ios_simulator() {
|
||||
shutdown_ios_simulator
|
||||
|
||||
# kill them with fire
|
||||
while pgrep -qx Simulator com.apple.CoreSimulator.CoreSimulatorService; do
|
||||
pkill -9 -x Simulator com.apple.CoreSimulator.CoreSimulatorService || true
|
||||
sleep 0.05
|
||||
done
|
||||
|
||||
# - Prod `simctl` a few times as sometimes it fails the first couple of times after switching XCode vesions
|
||||
local deadline=$((SECONDS+5))
|
||||
while [ -z "$(xcrun simctl list devices 2>/dev/null)" ] && [ $SECONDS -lt $deadline ]; do
|
||||
: # nothing to see here, will stop cycling on the first successful run
|
||||
done
|
||||
|
||||
# - Choose a device, if it has not already been chosen
|
||||
local deadline=$((SECONDS+5))
|
||||
IOS_DEVICE=""
|
||||
while [ -z "$IOS_DEVICE" ] && [ $SECONDS -lt $deadline ]; do
|
||||
IOS_DEVICE="$(ruby $SRCROOT/scripts/find-ios-device.rb best)"
|
||||
done
|
||||
if [ -z "$IOS_DEVICE" ]; then
|
||||
echo "*** Failed to determine the iOS Simulator device to use ***"
|
||||
exit 1
|
||||
fi
|
||||
export IOS_SIM_DEVICE=$IOS_DEVICE
|
||||
|
||||
# - Reset the device we will be using if running in CI
|
||||
xcrun simctl shutdown "$IOS_SIM_DEVICE" 1>/dev/null 2>/dev/null || true # sometimes simctl gets confused
|
||||
xcrun simctl erase "$IOS_SIM_DEVICE"
|
||||
|
||||
# - Start the target in Simulator.app
|
||||
# Note: as of Xcode 7.3.1 `simctl` can not completely boot a simulator, specifically it can not bring up backboard, so GUI apps can not run.
|
||||
# This is fixed in version 8 of Xcode, but we still need the compatibility
|
||||
|
||||
"$DEVELOPER_DIR/Applications/Simulator.app/Contents/MacOS/Simulator" -CurrentDeviceUDID "$IOS_SIM_DEVICE" & # will get killed with all other children at exit
|
||||
startedSimulator=true
|
||||
|
||||
else
|
||||
# - ensure that the simulator is running on a developer's workstation
|
||||
open "$DEVELOPER_DIR/Applications/Simulator.app"
|
||||
|
||||
# - Select the first device booted in the simulator, since it will boot something for us
|
||||
local deadline=$((SECONDS+10))
|
||||
IOS_DEVICE=""
|
||||
while [ -z "$IOS_DEVICE" ] && [ $SECONDS -lt $deadline ]; do
|
||||
IOS_DEVICE="$(ruby $SRCROOT/scripts/find-ios-device.rb booted)"
|
||||
done
|
||||
if [ -z "$IOS_DEVICE" ]; then
|
||||
echo "*** Failed to determine the iOS Simulator device in use ***"
|
||||
exit 1
|
||||
fi
|
||||
export IOS_SIM_DEVICE=$IOS_DEVICE
|
||||
fi
|
||||
|
||||
# Wait until the boot completes
|
||||
printf " waiting for simulator (%s) to boot..." "$IOS_SIM_DEVICE"
|
||||
until ruby -rjson -e "exit JSON.parse(%x{xcrun simctl list devices --json})['devices'].flat_map { |d| d[1] }.any? { |d| d['availability'] == '(available)' && d['state'] == 'Booted' }"; do
|
||||
sleep 0.25
|
||||
done
|
||||
echo " done"
|
||||
echo "It will take some time before the simulator is fully ready, continuing on to other work"
|
||||
#delete test simulator
|
||||
xcrun simctl delete ${SIM_DEVICE_NAME} || true
|
||||
}
|
||||
|
||||
# Cleanup now and also cleanup when this script exits.
|
||||
cleanup
|
||||
cleanup >/dev/null 2>&1
|
||||
trap cleanup EXIT
|
||||
|
||||
# Use a consistent version of Node if possible.
|
||||
@ -298,7 +248,7 @@ case "$TARGET" in
|
||||
start_packager
|
||||
|
||||
pushd ios
|
||||
xctest ReactTestApp
|
||||
xctest ReactTests
|
||||
stop_server
|
||||
;;
|
||||
"react-example")
|
||||
@ -309,8 +259,11 @@ case "$TARGET" in
|
||||
open_chrome
|
||||
start_packager
|
||||
|
||||
echo "{ \"test\" : true }" > $(pwd)/components/params.json
|
||||
pushd ios
|
||||
xctest ReactExample
|
||||
popd
|
||||
echo "{}" > $(pwd)/components/params.json
|
||||
;;
|
||||
"react-tests-android")
|
||||
npm run check-environment
|
||||
@ -322,21 +275,25 @@ case "$TARGET" in
|
||||
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
||||
XCPRETTY=''
|
||||
|
||||
pushd tests/react-test-app
|
||||
pushd react-native/android
|
||||
$(pwd)/gradlew publishAndroid
|
||||
popd
|
||||
|
||||
pushd tests/react-test-app
|
||||
npm install
|
||||
|
||||
echo "Resetting logcat"
|
||||
# Despite the docs claiming -c to work, it doesn't, so `-T 1` alleviates that.
|
||||
mkdir -p $(pwd)/build || true
|
||||
adb logcat -c
|
||||
adb logcat -T 1 | tee "$LOGCAT_OUT" &
|
||||
adb logcat -T 1 | tee "$LOGCAT_OUT" | tee $(pwd)/build/out.txt &
|
||||
|
||||
./run-android.sh
|
||||
|
||||
echo "Start listening for Test completion"
|
||||
|
||||
while :; do
|
||||
if grep -q "__REALM_REACT_ANDROID_TESTS_COMPLETED__" "$LOGCAT_OUT"; then
|
||||
if grep -q "__REALM_JS_TESTS_COMPLETED__" "$LOGCAT_OUT"; then
|
||||
break
|
||||
else
|
||||
echo "Waiting for tests."
|
||||
@ -352,7 +309,8 @@ case "$TARGET" in
|
||||
echo "********* TESTS COMPLETED *********";
|
||||
echo "********* File location: $(pwd)/tests.xml *********";
|
||||
cat tests.xml
|
||||
|
||||
|
||||
check_test_results ReactTests
|
||||
;;
|
||||
"node")
|
||||
npm run check-environment
|
||||
|
@ -887,9 +887,8 @@
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "node ../scripts/download-realm.js ios --sync";
|
||||
showEnvVarsInLog = 0;
|
||||
shellPath = "/bin/sh";
|
||||
shellScript = "[ -z \"$NVM_DIR\" ] && export NVM_DIR=\"$HOME/.nvm\"\n\nif [[ -s \"$HOME/.nvm/nvm.sh\" ]]; then\n . \"$HOME/.nvm/nvm.sh\"\nelif [[ -x \"$(command -v brew)\" && -s \"$(brew --prefix nvm)/nvm.sh\" ]]; then\n . \"$(brew --prefix nvm)/nvm.sh\"\nfi\n \nif [[ \"$(command -v nvm)\" ]]; then\n nvm install 7.10.0\nfi\n \n node ../scripts/download-realm.js ios --sync";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
|
@ -56,7 +56,7 @@ function runTests() {
|
||||
|
||||
return Object.keys(testNames).reduce((suitePromiseChain, suiteName) => {
|
||||
return suitePromiseChain.then(() => {
|
||||
console.log('Starting ' + suiteName);
|
||||
console.warn('Starting ' + suiteName);
|
||||
|
||||
return testNames[suiteName].reduce((testPromiseChain, testName) => {
|
||||
return testPromiseChain.then(() => {
|
||||
@ -64,7 +64,7 @@ function runTests() {
|
||||
}).then(() => {
|
||||
return RealmTests.runTest(suiteName, testName);
|
||||
}).then(() => {
|
||||
console.log('+ ' + testName);
|
||||
console.warn('+ ' + testName);
|
||||
}, (err) => {
|
||||
console.warn('- ' + testName);
|
||||
console.warn(err.message || err);
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
const require_method = require;
|
||||
function node_require(module) {
|
||||
return require(module);
|
||||
return require_method(module);
|
||||
}
|
||||
|
||||
const Realm = node_require('realm');
|
||||
|
@ -203,7 +203,12 @@ module.exports = {
|
||||
},
|
||||
|
||||
assertType: function(value, type, depth) {
|
||||
this.assertEqual(typeof value, type, `Value ${value} expected to be of type ${type}`, 1 + depth || 0);
|
||||
try {
|
||||
this.assertEqual(typeof value, type, "", 1 + depth || 0);
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error(`Value ${value} expected to be of type ${type}`)
|
||||
}
|
||||
},
|
||||
|
||||
assertDefined: function(value, errorMessage, depth) {
|
||||
|
@ -27,7 +27,8 @@ if( typeof Realm.Sync !== 'undefined' && Realm.Sync !== null ) {
|
||||
}
|
||||
|
||||
const isNodeProcess = typeof process === 'object' && process + '' === '[object process]';
|
||||
function node_require(module) { return require(module); }
|
||||
const require_method = require;
|
||||
function node_require(module) { return require_method(module); }
|
||||
|
||||
if (isNodeProcess && process.platform === 'win32') {
|
||||
global.enableSyncTests = false;
|
||||
@ -113,7 +114,7 @@ exports.runTest = function(suiteName, testName) {
|
||||
if (testMethod) {
|
||||
// Start fresh in case of a crash in a previous run.
|
||||
Realm.clearTestState();
|
||||
console.log("Starting test " + testName);
|
||||
console.warn("Starting test " + testName);
|
||||
var promise;
|
||||
try {
|
||||
promise = testMethod.call(testSuite);
|
||||
|
@ -32,15 +32,13 @@ const DATE3 = new Date(3);
|
||||
module.exports = {
|
||||
testListConstructor: function() {
|
||||
const realm = new Realm({schema: [schemas.PersonObject, schemas.PersonList]});
|
||||
|
||||
realm.write(() => {
|
||||
let obj = realm.create('PersonList', {list: []});
|
||||
TestCase.assertInstanceOf(obj.list, Realm.List);
|
||||
TestCase.assertInstanceOf(obj.list, Realm.Collection);
|
||||
});
|
||||
|
||||
|
||||
TestCase.assertThrowsContaining(() => new Realm.List(), 'constructor');
|
||||
|
||||
TestCase.assertInstanceOf(Realm.List, Function);
|
||||
},
|
||||
|
||||
|
@ -386,35 +386,36 @@ module.exports = {
|
||||
|
||||
testResultsFindIndexOfObject: function() {
|
||||
var realm = new Realm({schema: [schemas.TestObject]});
|
||||
|
||||
|
||||
var object1, object2, object3;
|
||||
realm.write(function() {
|
||||
object1 = realm.create('TestObject', {doubleCol: 1});
|
||||
object2 = realm.create('TestObject', {doubleCol: 2});
|
||||
object3 = realm.create('TestObject', {doubleCol: 2});
|
||||
});
|
||||
|
||||
|
||||
// Search in base table
|
||||
const objects = realm.objects('TestObject');
|
||||
TestCase.assertEqual(objects.indexOf(object1), 0);
|
||||
TestCase.assertEqual(objects.indexOf(object2), 1);
|
||||
TestCase.assertEqual(objects.indexOf(object3), 2);
|
||||
|
||||
|
||||
// Search in filtered query
|
||||
const results = objects.filtered("doubleCol == 2");
|
||||
TestCase.assertEqual(results.indexOf(object1), -1);
|
||||
TestCase.assertEqual(results.indexOf(object2), 0);
|
||||
TestCase.assertEqual(results.indexOf(object3), 1);
|
||||
|
||||
|
||||
const nonRealmObject = {test: "this is an object"};
|
||||
TestCase.assertEqual(objects.indexOf(nonRealmObject), -1);
|
||||
|
||||
|
||||
// Searching for object from the wrong realm
|
||||
var realm2 = new Realm({path: '2.realm', schema: realm.schema});
|
||||
var object4;
|
||||
realm2.write(function() {
|
||||
object4 = realm2.create('TestObject', {doubleCol: 1});
|
||||
});
|
||||
|
||||
TestCase.assertThrows(function() {
|
||||
objects.indexOf(object4);
|
||||
});
|
||||
|
@ -27,8 +27,9 @@ const TestCase = require('./asserts');
|
||||
|
||||
const isNodeProccess = (typeof process === 'object' && process + '' === '[object process]');
|
||||
|
||||
const require_method = require;
|
||||
function node_require(module) {
|
||||
return require(module);
|
||||
return require_method(module);
|
||||
}
|
||||
|
||||
let tmp;
|
||||
|
@ -142,6 +142,8 @@ dependencies {
|
||||
compile "com.facebook.react:react-native:+" // From node_modules
|
||||
compile project(":realm")
|
||||
compile project(":react-native-fs")
|
||||
compile project(':react-native-exception-handler')
|
||||
compile project(':react-native-exit-app-no-history')
|
||||
}
|
||||
|
||||
// Run this once to be able to run the application with BUCK
|
||||
|
@ -4,6 +4,8 @@ import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.react.ReactApplication;
|
||||
import com.masteratul.exceptionhandler.ReactNativeExceptionHandlerPackage;
|
||||
import com.github.wumke.RNExitApp.RNExitAppPackage;
|
||||
import com.facebook.react.ReactInstanceManager;
|
||||
import com.facebook.react.ReactNativeHost;
|
||||
import com.facebook.react.ReactPackage;
|
||||
@ -20,7 +22,7 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
|
||||
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
|
||||
@Override
|
||||
protected boolean getUseDeveloperSupport() {
|
||||
public boolean getUseDeveloperSupport() {
|
||||
return BuildConfig.DEBUG;
|
||||
}
|
||||
|
||||
@ -28,6 +30,8 @@ public class MainApplication extends Application implements ReactApplication {
|
||||
protected List<ReactPackage> getPackages() {
|
||||
return Arrays.<ReactPackage>asList(
|
||||
new MainReactPackage(),
|
||||
new ReactNativeExceptionHandlerPackage(),
|
||||
new RNExitAppPackage(),
|
||||
new RNFSPackage(),
|
||||
new RealmReactPackage()
|
||||
);
|
||||
|
@ -7,3 +7,9 @@ project(':realm').projectDir = new File(settingsDir, '../node_modules/realm/andr
|
||||
|
||||
include ':react-native-fs'
|
||||
project(':react-native-fs').projectDir = new File(settingsDir, '../node_modules/react-native-fs/android')
|
||||
|
||||
include ':react-native-exception-handler'
|
||||
project(':react-native-exception-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exception-handler/android')
|
||||
|
||||
include ':react-native-exit-app-no-history'
|
||||
project(':react-native-exit-app-no-history').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exit-app-no-history/android')
|
||||
|
@ -33,13 +33,13 @@ import { getTestNames, runTest } from './tests';
|
||||
async function runTests() {
|
||||
let testNames = getTestNames();
|
||||
let rootXml = builder.create('testsuites');
|
||||
|
||||
let failingTests = [];
|
||||
for (let suiteName in testNames) {
|
||||
let itemTestsuite = rootXml.ele('testsuite');
|
||||
let nbrTests = 0;
|
||||
let nbrFailures = 0;
|
||||
|
||||
console.log('Starting ' + suiteName);
|
||||
console.error('Starting ' + suiteName);
|
||||
|
||||
for (let testName of testNames[suiteName]) {
|
||||
nbrTests++;
|
||||
@ -51,6 +51,7 @@ async function runTests() {
|
||||
await runTest(suiteName, testName);
|
||||
}
|
||||
catch (e) {
|
||||
failingTests.push(`${suiteName}: ${testName} : Error ${e.message}`);
|
||||
itemTest.ele('error', {'message': e.message, 'stacktrace': e.stack}, e.toString());
|
||||
nbrFailures++;
|
||||
}
|
||||
@ -73,11 +74,19 @@ async function runTests() {
|
||||
// write the unit tests reports
|
||||
try {
|
||||
await RNFS.writeFile('/sdcard/tests.xml', xmlString, 'utf8');
|
||||
console.log('__REALM_REACT_ANDROID_TESTS_COMPLETED__');
|
||||
console.log('__REALM_JS_TESTS_COMPLETED__');
|
||||
if (failingTests.length !== 0) {
|
||||
console.error('\n\nREALM_FAILING_TESTS\n');
|
||||
console.error(failingTests);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
finally {
|
||||
console.warn("Realm Tests App finished. Exiting. Disable this to debug the app locally");
|
||||
RNExitApp.exitApp();
|
||||
}
|
||||
}
|
||||
|
||||
class ReactTests extends React.Component {
|
||||
|
@ -19,23 +19,109 @@
|
||||
'use strict';
|
||||
|
||||
import {
|
||||
Alert,
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View,
|
||||
} from 'react-native';
|
||||
|
||||
import builder from 'xmlbuilder';
|
||||
import React from 'react';
|
||||
import { runTests } from './tests';
|
||||
import { getTestNames, runTest } from './tests';
|
||||
import RNFS from 'react-native-fs';
|
||||
import RNExitApp from 'react-native-exit-app-no-history';
|
||||
|
||||
// import {setJSExceptionHandler} from 'react-native-exception-handler';
|
||||
// import {setNativeExceptionHandler} from 'react-native-exception-handler/index';
|
||||
|
||||
// setNativeExceptionHandler((exceptionString) => {
|
||||
// console.error("\nRealm Tests App FAILED. NATIVE ERROR\n");
|
||||
// console.error(`\n${exceptionString}\n`);
|
||||
// RNExitApp.exitApp();
|
||||
// });
|
||||
|
||||
// //unhandled JS exceptions handler
|
||||
// setJSExceptionHandler((error, isFatal) => {
|
||||
// console.error("\nRealm Tests App FAILED. JS ERROR\n");
|
||||
// console.error(`\n${error}\n`);
|
||||
// RNExitApp.exitApp();
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
async function runTests() {
|
||||
try {
|
||||
let testNames = getTestNames();
|
||||
let rootXml = builder.create('testsuites');
|
||||
let failingTests = [];
|
||||
for (let suiteName in testNames) {
|
||||
let itemTestsuite = rootXml.ele('testsuite');
|
||||
let nbrTests = 0;
|
||||
let nbrFailures = 0;
|
||||
|
||||
console.error('Starting ' + suiteName);
|
||||
|
||||
for (let testName of testNames[suiteName]) {
|
||||
nbrTests++;
|
||||
|
||||
let itemTest = itemTestsuite.ele('testcase');
|
||||
itemTest.att('name', testName);
|
||||
|
||||
try {
|
||||
await runTest(suiteName, testName);
|
||||
}
|
||||
catch (e) {
|
||||
failingTests.push(`${suiteName}: ${testName} : Error ${e.message}`);
|
||||
itemTest.ele('error', {'message': e.message, 'stacktrace': e.stack}, e.toString());
|
||||
nbrFailures++;
|
||||
}
|
||||
}
|
||||
|
||||
// update Junit XML report
|
||||
itemTestsuite.att('name', suiteName);
|
||||
itemTestsuite.att('tests', nbrTests);
|
||||
itemTestsuite.att('failures', nbrFailures);
|
||||
itemTestsuite.att('timestamp', "2016-01-22T14:40:44.874443-05:00");//TODO use real timestamp
|
||||
|
||||
}
|
||||
// export unit tests results
|
||||
let xmlString = rootXml.end({
|
||||
pretty: true,
|
||||
indent: ' ',
|
||||
newline: '\n',
|
||||
});
|
||||
|
||||
// write the unit tests reports
|
||||
const path = RNFS.MainBundlePath + "/tests.xml";
|
||||
await RNFS.writeFile(path, xmlString, 'utf8');
|
||||
|
||||
//using console.log output is not shown in Release builds. using console.warn
|
||||
console.warn(xmlString);
|
||||
console.warn('__REALM_JS_TESTS_COMPLETED__');
|
||||
if (failingTests.length !== 0) {
|
||||
console.error('\n\nREALM_FAILING_TESTS\n');
|
||||
console.error(failingTests);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
finally {
|
||||
console.warn("Realm Tests App finished. Exiting. Disable this to debug the app locally");
|
||||
RNExitApp.exitApp();
|
||||
}
|
||||
}
|
||||
|
||||
class ReactTests extends React.Component {
|
||||
render() {
|
||||
runTests();
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.button} onPress={runTests}>
|
||||
Tap to Run Tests
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
{'\n'}REALM-JS TESTS{'\n'}
|
||||
|
||||
Press Cmd+R to reload,{'\n'}
|
||||
Cmd+D or shake for dev menu
|
||||
</Text>
|
||||
|
@ -21,7 +21,9 @@
|
||||
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
|
||||
140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
|
||||
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
|
||||
1A31425AAD0B4731BDD7361C /* libReactNativeExceptionHandler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9BDA39DE0BF646F2AF670F18 /* libReactNativeExceptionHandler.a */; };
|
||||
1A9D2B80E7D649D2B5D8FE09 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 4E45185577984C00AA740BFE /* libz.tbd */; };
|
||||
1C2471A6B2544BF3BD9D9C10 /* libRNExitApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9DAA9FCB85294F77873D2769 /* libRNExitApp.a */; };
|
||||
5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };
|
||||
66DA50ADC4F24D88856B9051 /* libRealmReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 629FEF95D64747E9A56D4D0C /* libRealmReact.a */; };
|
||||
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
|
||||
@ -31,6 +33,7 @@
|
||||
855301D31E2006F700FF108E /* RealmReactTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 855301D11E2006F400FF108E /* RealmReactTests.m */; };
|
||||
A4CEF4BB1F7F862D00BA3B26 /* sync-v1.realm in Resources */ = {isa = PBXBuildFile; fileRef = A4CEF4BA1F7F862D00BA3B26 /* sync-v1.realm */; };
|
||||
E2050A7A5BE14CEA9A9E0722 /* libc++.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B37A7097A134D5CBB4C462A /* libc++.tbd */; };
|
||||
FD7EF00801C34983A6188E6E /* libRNFS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EBE9BC51D4A4EF79B40A51A /* libRNFS.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@ -223,6 +226,90 @@
|
||||
remoteGlobalIDString = F60690131CA2766F0003FB26;
|
||||
remoteInfo = RealmReact;
|
||||
};
|
||||
A474395F1FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 3DBE0D001F3B181A0099AA32;
|
||||
remoteInfo = fishhook;
|
||||
};
|
||||
A47439611FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 3DBE0D0D1F3B181C0099AA32;
|
||||
remoteInfo = "fishhook-tvOS";
|
||||
};
|
||||
A47439711FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 139D7ECE1E25DB7D00323FB7;
|
||||
remoteInfo = "third-party";
|
||||
};
|
||||
A47439731FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 3D383D3C1EBD27B6005632C8;
|
||||
remoteInfo = "third-party-tvOS";
|
||||
};
|
||||
A47439751FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 139D7E881E25C6D100323FB7;
|
||||
remoteInfo = "double-conversion";
|
||||
};
|
||||
A47439771FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 3D383D621EBD27B9005632C8;
|
||||
remoteInfo = "double-conversion-tvOS";
|
||||
};
|
||||
A47439791FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 9936F3131F5F2E4B0010BF04;
|
||||
remoteInfo = privatedata;
|
||||
};
|
||||
A474397B1FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 9936F32F1F5F2E5B0010BF04;
|
||||
remoteInfo = "privatedata-tvOS";
|
||||
};
|
||||
A47439801FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = FC81504B0B8B47808E93B553 /* RNFS.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = F12AFB9B1ADAF8F800E0535D;
|
||||
remoteInfo = RNFS;
|
||||
};
|
||||
A47439821FCF49A00034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = FC81504B0B8B47808E93B553 /* RNFS.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 6456441F1EB8DA9100672408;
|
||||
remoteInfo = "RNFS-tvOS";
|
||||
};
|
||||
A47439BA1FCF55E80034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 5E54C8D078F84427A9DEE242 /* RNExitApp.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 15209BEF1D250F63000D0F44;
|
||||
remoteInfo = RNExitApp;
|
||||
};
|
||||
A47439F11FCF586E0034D32F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = E65B8206DCD647B896F86688 /* ReactNativeExceptionHandler.xcodeproj */;
|
||||
proxyType = 2;
|
||||
remoteGlobalIDString = 134814201AA4EA6300B7C361;
|
||||
remoteInfo = ReactNativeExceptionHandler;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@ -245,8 +332,10 @@
|
||||
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
|
||||
193A0C4F1D2C485DBE5ACC72 /* RealmReact.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RealmReact.xcodeproj; path = "../node_modules/realm/react-native/ios/RealmReact.xcodeproj"; sourceTree = "<group>"; };
|
||||
4E45185577984C00AA740BFE /* libz.tbd */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
|
||||
5E54C8D078F84427A9DEE242 /* RNExitApp.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNExitApp.xcodeproj; path = "../node_modules/react-native-exit-app-no-history/ios/RNExitApp.xcodeproj"; sourceTree = "<group>"; };
|
||||
5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = "<group>"; };
|
||||
629FEF95D64747E9A56D4D0C /* libRealmReact.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRealmReact.a; sourceTree = "<group>"; };
|
||||
6EBE9BC51D4A4EF79B40A51A /* libRNFS.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNFS.a; sourceTree = "<group>"; };
|
||||
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = "<group>"; };
|
||||
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = "<group>"; };
|
||||
8553016A1E1FF6D500FF108E /* RealmJSTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RealmJSTests.mm; path = ../../ios/RealmJSTests.mm; sourceTree = "<group>"; };
|
||||
@ -254,7 +343,11 @@
|
||||
855301CE1E20069D00FF108E /* dates-v5.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "dates-v5.realm"; sourceTree = "<group>"; };
|
||||
855301D11E2006F400FF108E /* RealmReactTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RealmReactTests.m; path = ReactTests/RealmReactTests.m; sourceTree = "<group>"; };
|
||||
8B37A7097A134D5CBB4C462A /* libc++.tbd */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
|
||||
9BDA39DE0BF646F2AF670F18 /* libReactNativeExceptionHandler.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libReactNativeExceptionHandler.a; sourceTree = "<group>"; };
|
||||
9DAA9FCB85294F77873D2769 /* libRNExitApp.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNExitApp.a; sourceTree = "<group>"; };
|
||||
A4CEF4BA1F7F862D00BA3B26 /* sync-v1.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "sync-v1.realm"; sourceTree = "<group>"; };
|
||||
E65B8206DCD647B896F86688 /* ReactNativeExceptionHandler.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = ReactNativeExceptionHandler.xcodeproj; path = "../node_modules/react-native-exception-handler/ios/ReactNativeExceptionHandler.xcodeproj"; sourceTree = "<group>"; };
|
||||
FC81504B0B8B47808E93B553 /* RNFS.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFS.xcodeproj; path = "../node_modules/react-native-fs/RNFS.xcodeproj"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -284,6 +377,9 @@
|
||||
66DA50ADC4F24D88856B9051 /* libRealmReact.a in Frameworks */,
|
||||
E2050A7A5BE14CEA9A9E0722 /* libc++.tbd in Frameworks */,
|
||||
1A9D2B80E7D649D2B5D8FE09 /* libz.tbd in Frameworks */,
|
||||
FD7EF00801C34983A6188E6E /* libRNFS.a in Frameworks */,
|
||||
1C2471A6B2544BF3BD9D9C10 /* libRNExitApp.a in Frameworks */,
|
||||
1A31425AAD0B4731BDD7361C /* libReactNativeExceptionHandler.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -346,6 +442,8 @@
|
||||
children = (
|
||||
139FDEF41B06529B00C62182 /* libRCTWebSocket.a */,
|
||||
3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */,
|
||||
A47439601FCF49A00034D32F /* libfishhook.a */,
|
||||
A47439621FCF49A00034D32F /* libfishhook-tvOS.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -375,6 +473,12 @@
|
||||
3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */,
|
||||
3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */,
|
||||
3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */,
|
||||
A47439721FCF49A00034D32F /* libthird-party.a */,
|
||||
A47439741FCF49A00034D32F /* libthird-party.a */,
|
||||
A47439761FCF49A00034D32F /* libdouble-conversion.a */,
|
||||
A47439781FCF49A00034D32F /* libdouble-conversion.a */,
|
||||
A474397A1FCF49A00034D32F /* libprivatedata.a */,
|
||||
A474397C1FCF49A00034D32F /* libprivatedata-tvOS.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -400,7 +504,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */,
|
||||
5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */,
|
||||
5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -429,6 +533,9 @@
|
||||
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */,
|
||||
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */,
|
||||
193A0C4F1D2C485DBE5ACC72 /* RealmReact.xcodeproj */,
|
||||
FC81504B0B8B47808E93B553 /* RNFS.xcodeproj */,
|
||||
5E54C8D078F84427A9DEE242 /* RNExitApp.xcodeproj */,
|
||||
E65B8206DCD647B896F86688 /* ReactNativeExceptionHandler.xcodeproj */,
|
||||
);
|
||||
name = Libraries;
|
||||
sourceTree = "<group>";
|
||||
@ -486,6 +593,31 @@
|
||||
path = ../../data;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A474394A1FCF49A00034D32F /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A47439811FCF49A00034D32F /* libRNFS.a */,
|
||||
A47439831FCF49A00034D32F /* libRNFS.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A47439951FCF55E80034D32F /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A47439BB1FCF55E80034D32F /* libRNExitApp.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A47439CD1FCF586E0034D32F /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
A47439F21FCF586E0034D32F /* libReactNativeExceptionHandler.a */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@ -596,10 +728,22 @@
|
||||
ProductGroup = 146834001AC3E56700842450 /* Products */;
|
||||
ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A47439CD1FCF586E0034D32F /* Products */;
|
||||
ProjectRef = E65B8206DCD647B896F86688 /* ReactNativeExceptionHandler.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = 855301781E1FF78600FF108E /* Products */;
|
||||
ProjectRef = 193A0C4F1D2C485DBE5ACC72 /* RealmReact.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A47439951FCF55E80034D32F /* Products */;
|
||||
ProjectRef = 5E54C8D078F84427A9DEE242 /* RNExitApp.xcodeproj */;
|
||||
},
|
||||
{
|
||||
ProductGroup = A474394A1FCF49A00034D32F /* Products */;
|
||||
ProjectRef = FC81504B0B8B47808E93B553 /* RNFS.xcodeproj */;
|
||||
},
|
||||
);
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
@ -764,10 +908,10 @@
|
||||
remoteRef = 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */ = {
|
||||
5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = "libRCTAnimation-tvOS.a";
|
||||
path = libRCTAnimation.a;
|
||||
remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
@ -792,6 +936,90 @@
|
||||
remoteRef = 855301941E1FF78600FF108E /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439601FCF49A00034D32F /* libfishhook.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libfishhook.a;
|
||||
remoteRef = A474395F1FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439621FCF49A00034D32F /* libfishhook-tvOS.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = "libfishhook-tvOS.a";
|
||||
remoteRef = A47439611FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439721FCF49A00034D32F /* libthird-party.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = "libthird-party.a";
|
||||
remoteRef = A47439711FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439741FCF49A00034D32F /* libthird-party.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = "libthird-party.a";
|
||||
remoteRef = A47439731FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439761FCF49A00034D32F /* libdouble-conversion.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = "libdouble-conversion.a";
|
||||
remoteRef = A47439751FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439781FCF49A00034D32F /* libdouble-conversion.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = "libdouble-conversion.a";
|
||||
remoteRef = A47439771FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A474397A1FCF49A00034D32F /* libprivatedata.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libprivatedata.a;
|
||||
remoteRef = A47439791FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A474397C1FCF49A00034D32F /* libprivatedata-tvOS.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = "libprivatedata-tvOS.a";
|
||||
remoteRef = A474397B1FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439811FCF49A00034D32F /* libRNFS.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libRNFS.a;
|
||||
remoteRef = A47439801FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439831FCF49A00034D32F /* libRNFS.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libRNFS.a;
|
||||
remoteRef = A47439821FCF49A00034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439BB1FCF55E80034D32F /* libRNExitApp.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libRNExitApp.a;
|
||||
remoteRef = A47439BA1FCF55E80034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
A47439F21FCF586E0034D32F /* libReactNativeExceptionHandler.a */ = {
|
||||
isa = PBXReferenceProxy;
|
||||
fileType = archive.ar;
|
||||
path = libReactNativeExceptionHandler.a;
|
||||
remoteRef = A47439F11FCF586E0034D32F /* PBXContainerItemProxy */;
|
||||
sourceTree = BUILT_PRODUCTS_DIR;
|
||||
};
|
||||
/* End PBXReferenceProxy section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
@ -829,7 +1057,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
|
||||
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
@ -889,6 +1117,9 @@
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ReactTests.app/ReactTests";
|
||||
@ -907,6 +1138,9 @@
|
||||
LIBRARY_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
"\"$(SRCROOT)/$(TARGET_NAME)\"",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ReactTests.app/ReactTests";
|
||||
@ -921,6 +1155,7 @@
|
||||
INFOPLIST_FILE = ReactTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.realm.ReactTests;
|
||||
PRODUCT_NAME = ReactTests;
|
||||
};
|
||||
name = Debug;
|
||||
@ -932,6 +1167,7 @@
|
||||
INFOPLIST_FILE = ReactTests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.realm.ReactTests;
|
||||
PRODUCT_NAME = ReactTests;
|
||||
};
|
||||
name = Release;
|
||||
|
@ -1,5 +1,15 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
|
@ -3,18 +3,23 @@
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "react-native start"
|
||||
"start": "node node_modules/react-native/local-cli/cli.js start"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "~15.4.0-rc.4",
|
||||
"react-native": "0.40.0",
|
||||
"react-native-fs": "^1.1.0",
|
||||
"react": "16.0.0",
|
||||
"react-native": "0.50.4",
|
||||
"react-native-exception-handler": "^2.4.3",
|
||||
"react-native-exit-app-no-history": "^1.0.2",
|
||||
"react-native-fs": "^2.8.5",
|
||||
"realm": "file:../..",
|
||||
"realm-tests": "file:../js",
|
||||
"xmlbuilder": "^4.2.1"
|
||||
},
|
||||
"resolutions": {
|
||||
"moment": "2.19.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-preset-react-native": "1.9.1",
|
||||
"babel-preset-react-native": "4.0.0",
|
||||
"invariant": "^2.2.2"
|
||||
}
|
||||
}
|
||||
|
8
tests/react-test-app/tests/index.js
vendored
8
tests/react-test-app/tests/index.js
vendored
@ -52,7 +52,7 @@ export async function runTests() {
|
||||
let passed = true;
|
||||
|
||||
for (let suiteName in testNames) {
|
||||
console.log('Starting ' + suiteName);
|
||||
console.warn('Starting ' + suiteName);
|
||||
|
||||
for (let testName of testNames[suiteName]) {
|
||||
try {
|
||||
@ -72,11 +72,11 @@ export async function runTest(suiteName, testName) {
|
||||
|
||||
try {
|
||||
await RealmTests.runTest(suiteName, testName);
|
||||
console.log('+ ' + testName);
|
||||
console.warn('+ ' + testName);
|
||||
}
|
||||
catch (e) {
|
||||
console.warn('- ' + testName);
|
||||
console.warn(e.message || e);
|
||||
console.error('- ' + testName);
|
||||
console.error(e.message || e);
|
||||
throw e;
|
||||
}
|
||||
finally {
|
||||
|
Loading…
x
Reference in New Issue
Block a user