Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit cb5e8a2

Browse files
committed
readme modifications, removed copyrights, fixed issue with install update test
1 parent b6a9e1b commit cb5e8a2

File tree

8 files changed

+86
-48
lines changed

8 files changed

+86
-48
lines changed

Examples/CodePushDemoApp/CodePushDemoApp.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10-
008F07F31AC5B25A0029DE68 /* main.jsbundle in Resources */ = {isa = PBXBuildFile; fileRef = 008F07F21AC5B25A0029DE68 /* main.jsbundle */; };
1110
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
1211
00C302E61ABCBA2D00DB3ED1 /* libRCTAdSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302B41ABCB8E700DB3ED1 /* libRCTAdSupport.a */; };
1312
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@@ -22,11 +21,12 @@
2221
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
2322
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
2423
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
24+
544161591B8BCA81000D9E25 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
25+
5441615B1B8BF2BB000D9E25 /* main.jsbundle in Resources */ = {isa = PBXBuildFile; fileRef = 5441615A1B8BF2BB000D9E25 /* main.jsbundle */; };
2526
5451ACBA1B86A5B600E2A7DF /* QueryUpdateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5451ACB81B86A5B600E2A7DF /* QueryUpdateTests.m */; };
2627
5451ACEC1B86E40A00E2A7DF /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5451ACEB1B86E34300E2A7DF /* libRCTTest.a */; };
2728
54D774BA1B87DAF800F2ABF8 /* ApplyUpdateTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 54D774B91B87DAF800F2ABF8 /* ApplyUpdateTests.m */; };
2829
81551E1B1B3B428000F5B9F1 /* libCodePush.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 81551E0F1B3B427200F5B9F1 /* libCodePush.a */; };
29-
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
3030
/* End PBXBuildFile section */
3131

3232
/* Begin PBXContainerItemProxy section */
@@ -131,7 +131,6 @@
131131
/* End PBXContainerItemProxy section */
132132

133133
/* Begin PBXFileReference section */
134-
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = iOS/main.jsbundle; sourceTree = "<group>"; };
135134
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = "<group>"; };
136135
00C302AF1ABCB8E700DB3ED1 /* RCTAdSupport.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAdSupport.xcodeproj; path = "node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj"; sourceTree = "<group>"; };
137136
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = "<group>"; };
@@ -150,6 +149,7 @@
150149
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = iOS/Info.plist; sourceTree = "<group>"; };
151150
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = iOS/main.m; sourceTree = "<group>"; };
152151
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
152+
5441615A1B8BF2BB000D9E25 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = iOS/main.jsbundle; sourceTree = "<group>"; };
153153
5451ACB81B86A5B600E2A7DF /* QueryUpdateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QueryUpdateTests.m; sourceTree = "<group>"; };
154154
5451ACE61B86E34300E2A7DF /* RCTTest.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTTest.xcodeproj; path = "node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj"; sourceTree = "<group>"; };
155155
54D774B91B87DAF800F2ABF8 /* ApplyUpdateTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplyUpdateTests.m; sourceTree = "<group>"; };
@@ -170,6 +170,7 @@
170170
isa = PBXFrameworksBuildPhase;
171171
buildActionMask = 2147483647;
172172
files = (
173+
544161591B8BCA81000D9E25 /* libRCTText.a in Frameworks */,
173174
5451ACEC1B86E40A00E2A7DF /* libRCTTest.a in Frameworks */,
174175
146834051AC3E58100842450 /* libReact.a in Frameworks */,
175176
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
@@ -179,7 +180,6 @@
179180
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */,
180181
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
181182
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
182-
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
183183
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
184184
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
185185
81551E1B1B3B428000F5B9F1 /* libCodePush.a in Frameworks */,
@@ -274,7 +274,7 @@
274274
13B07FAE1A68108700A75B9A /* CodePushDemoApp */ = {
275275
isa = PBXGroup;
276276
children = (
277-
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
277+
5441615A1B8BF2BB000D9E25 /* main.jsbundle */,
278278
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
279279
13B07FB01A68108700A75B9A /* AppDelegate.m */,
280280
13B07FB51A68108700A75B9A /* Images.xcassets */,
@@ -598,7 +598,7 @@
598598
isa = PBXResourcesBuildPhase;
599599
buildActionMask = 2147483647;
600600
files = (
601-
008F07F31AC5B25A0029DE68 /* main.jsbundle in Resources */,
601+
5441615B1B8BF2BB000D9E25 /* main.jsbundle in Resources */,
602602
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
603603
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
604604
);

Examples/CodePushDemoApp/CodePushDemoAppTests/ApplyUpdateTests.m

Lines changed: 66 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,98 @@
1-
/**
2-
* Copyright (c) 2015-present, Facebook, Inc.
3-
* All rights reserved.
4-
*
5-
* This source code is licensed under the BSD-style license found in the
6-
* LICENSE file in the root directory of this source tree. An additional grant
7-
* of patent rights can be found in the PATENTS file in the same directory.
8-
*/
9-
10-
111
#import <UIKit/UIKit.h>
122
#import <XCTest/XCTest.h>
133
#import <RCTTest/RCTTestRunner.h>
144

5+
#import "RCTBridge.h"
6+
#import "RCTBridgeModule.h"
7+
#import "RCTDefines.h"
8+
#import "RCTRootView.h"
9+
#import "RCTRedBox.h"
1510
#import "RCTAssert.h"
1611

12+
#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\""
13+
14+
#define TIMEOUT_SECONDS 60
15+
#define TEXT_TO_LOOK_FOR @"If you see this, you have successfully installed an update!"
16+
1717
@interface ApplyUpdateTests : XCTestCase
1818

1919
@end
2020

2121
@implementation ApplyUpdateTests
2222
{
2323
RCTTestRunner *_runner;
24+
NSString* app;
2425
}
2526

2627
- (void)setUp
2728
{
29+
app = @"CodePushDemoAppTests/ApplyUpdateTests/ApplyUpdateTestApp";
2830
#if __LP64__
2931
RCTAssert(false, @"Tests should be run on 32-bit device simulators (e.g. iPhone 5)");
3032
#endif
3133

3234
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
3335
RCTAssert(version.majorVersion == 8 || version.minorVersion == 3, @"Tests should be run on iOS 8.3, found %zd.%zd.%zd", version.majorVersion, version.minorVersion, version.patchVersion);
34-
_runner = RCTInitRunnerForApp(@"CodePushDemoAppTests/ApplyUpdateTests/ApplyUpdateTestApp", nil);
36+
}
37+
38+
39+
- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
40+
{
41+
if (test(view)) {
42+
return YES;
43+
}
44+
for (UIView *subview in [view subviews]) {
45+
if ([self findSubviewInView:subview matching:test]) {
46+
return YES;
47+
}
48+
}
49+
return NO;
3550
}
3651

3752
#pragma mark Logic Tests
3853
- (void)testDownloadAndApplyUpdate
3954
{
4055

41-
[_runner runTest:_cmd module:@"DownloadAndApplyUpdateTest"];
56+
57+
NSString *sanitizedAppName = [app stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
58+
sanitizedAppName = [sanitizedAppName stringByReplacingOccurrencesOfString:@"\\" withString:@"-"];
59+
NSURL* scriptURL;
60+
61+
#if RUNNING_ON_CI
62+
scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"];
63+
RCTAssert(_scriptURL != nil, @"Could not locate main.jsBundle");
64+
#else
65+
scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.includeRequire.runModule.bundle?dev=true", app]];
66+
#endif
67+
68+
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:scriptURL
69+
moduleProvider:nil
70+
launchOptions:nil];
71+
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"DownloadAndApplyUpdateTest"];
72+
73+
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
74+
BOOL foundElement = NO;
75+
NSString *redboxError = nil;
76+
77+
while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
78+
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
79+
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
80+
redboxError = [[RCTRedBox sharedInstance] currentErrorMessage];
81+
UIViewController *vc = [UIApplication sharedApplication].delegate.window.rootViewController;
82+
foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
83+
if ([NSStringFromClass([view class]) isEqualToString:@"RCTText"]){
84+
NSString *text = [(id)view textStorage].string;
85+
if ([text isEqualToString:TEXT_TO_LOOK_FOR]) {
86+
return YES;
87+
}
88+
}
89+
90+
return NO;
91+
}];
92+
}
93+
94+
XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
95+
XCTAssertTrue(foundElement, @"Cound't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
4296

4397
}
4498

Examples/CodePushDemoApp/CodePushDemoAppTests/ApplyUpdateTests/ApplyUpdateTestApp.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
/**
2-
* Copyright (c) 2015-present, Facebook, Inc.
3-
* All rights reserved.
4-
*
5-
* This source code is licensed under the BSD-style license found in the
6-
* LICENSE file in the root directory of this source tree. An additional grant
7-
* of patent rights can be found in the PATENTS file in the same directory.
8-
*
92
* @providesModule QueryUpdateTestApp
103
*/
114
'use strict';

Examples/CodePushDemoApp/CodePushDemoAppTests/ApplyUpdateTests/CodePushDemoApp.ios.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ var CodePushDemoApp = React.createClass({
2929
throw new Error("The local package is still different from the updated package after installation");
3030
}
3131
}
32-
RCTTestModule.markTestCompleted();
3332
}
3433
});
3534
},

Examples/CodePushDemoApp/CodePushDemoAppTests/ApplyUpdateTests/DownloadAndApplyUpdateTest.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
/**
2-
* Copyright (c) 2015-present, Facebook, Inc.
3-
* All rights reserved.
4-
*
5-
* This source code is licensed under the BSD-style license found in the
6-
* LICENSE file in the root directory of this source tree. An additional grant
7-
* of patent rights can be found in the PATENTS file in the same directory.
8-
*/
91
'use strict';
102

11-
var RCTTestModule = require('NativeModules').TestModule;
123
var React = require('react-native');
134
var CodePushSdk = require('react-native-code-push');
145
var NativeBridge = require('react-native').NativeModules.CodePush;

Examples/CodePushDemoApp/CodePushDemoAppTests/QueryUpdateTests.m

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
/**
2-
* Copyright (c) 2015-present, Facebook, Inc.
3-
* All rights reserved.
4-
*
5-
* This source code is licensed under the BSD-style license found in the
6-
* LICENSE file in the root directory of this source tree. An additional grant
7-
* of patent rights can be found in the PATENTS file in the same directory.
8-
*/
9-
10-
111
#import <UIKit/UIKit.h>
122
#import <XCTest/XCTest.h>
133
#import <RCTTest/RCTTestRunner.h>
144

155
#import "RCTAssert.h"
166

7+
#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\""
8+
179
@interface QueryUpdateTests : XCTestCase
1810

1911
@end

Examples/CodePushDemoApp/iOS/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
<key>NSLocationWhenInUseUsageDescription</key>
4040
<string></string>
4141
<key>CodePushDeploymentKey</key>
42-
<string>deployment-key-here</string>
42+
<string>3fd3773b-4554-4f56-b7d7-ce5b587f54de</string>
4343
<key>CodePushServerUrl</key>
44-
<string>server-url-here</string>
44+
<string>http://localhost:3000</string>
4545
</dict>
4646
</plist>

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ Running the Example
1010
* Start the CodePush server with `gulp serve`, after installing the prerequisites described in the [project readme](https://github.com/Microsoft/hybrid-mobile-deploy/blob/master/README.md)
1111
* From the root of this project, run `npm install`
1212
* `cd` into `Examples/CodePushDemoApp`
13-
* Open `index.ios.js` and add a deployment key (generate one using the UI at http://localhost:4000/)
13+
* From this demo app folder, run `npm install`
14+
* Open `Info.plist` and fill in the values for CodePushDeploymentKey and CodePushServerUrl
1415
* Run `npm start` to launch the packager
1516
* Open `CodePushDemoApp.xcodeproj` in Xcode
1617
* Launch the project
18+
19+
Running Tests
20+
---
21+
22+
* Open `CodePushDemoApp.xcodeproj` in Xcode
23+
* Navigate to the test explorer (small grey diamond near top left)
24+
* Click on the 'play' button next to CodePushDemoAppTests
25+
* After the tests are completed, green ticks should appear next to the test cases to indicate success

0 commit comments

Comments
 (0)