-
Notifications
You must be signed in to change notification settings - Fork 477
Create a macOS implementation of AsyncStorage + macOS example app and e2e tests #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
krizzu
merged 24 commits into
react-native-async-storage:LEGACY
from
tom-un:tomun/macos
Feb 27, 2020
Merged
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d9bda40
Switch to consume microsoft fork.
tom-un 04c5800
Mac test app.
tom-un 2d33f65
Merge remote-tracking branch 'as/LEGACY' into tomun/macos
tom-un 6d7d8f3
Create seperate macos xcodeproj. Refactor metro.config and react-nat…
tom-un 83269c9
Remove unused file
tom-un 69ab8eb
mac example building and working.
tom-un 3ea7ddf
Updated docs for macOS
tom-un 105134d
Simplified example test app
tom-un 1deb2d3
Got mac build/test scripts working
tom-un 66239e1
Added simple macOS XCUITest
tom-un 215323b
Add mac tests to circle ci
tom-un acc584f
Got simple test to click add 10 button and test results
tom-un 6cd308b
Implemented three macOS tests
tom-un 7c0c10b
Got all mac tests to parity with iOS.
tom-un 64574a5
Revert changes to ios xcodeproj
tom-un 3b2d939
XCUITests for macOS not supported on CCI. So just build the example …
tom-un 19ba4d3
Removed escape from string
tom-un 6ba4665
Attempt to test macOS using GitHub Actions
tom-un 9f46e99
Removed mac from CCI since CCI doesn't support mac tests.
tom-un 18216d1
Update docs/Linking.md
tom-un 7c643f4
Update example/macos/AsyncStorageExample-macOS/Info.plist
tom-un 54ea5a4
Changes per tido64 code review feedback.
tom-un fecdd1c
Removed redundant source files.
tom-un 526f6b3
Optimized 'test' e2e scripts to not reduntantly build.
tom-un File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- LEGACY | ||
pull_request: | ||
branches: | ||
- LEGACY | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: macOS-latest | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
- name: Installing Yarn dependencies | ||
run: yarn install | ||
- name: Build macOS app | ||
run: yarn build:e2e:macos | ||
- name: Run e2e tests | ||
run: yarn test:e2e:macos | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,9 @@ jsconfig.json | |
.eslintignore | ||
codecov.yml | ||
|
||
# Scripts | ||
scripts/ | ||
|
||
# Example | ||
example/ | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
example/macos/AsyncStorageExample-macOS/AppDelegate+RNCAsyncStorageDelegate.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "AppDelegate.h" | ||
|
||
#import <RNCAsyncStorage/RNCAsyncStorageDelegate.h> | ||
|
||
@interface AppDelegate (RNCAsyncStorageDelegate) <RNCAsyncStorageDelegate> | ||
@end |
65 changes: 65 additions & 0 deletions
65
example/macos/AsyncStorageExample-macOS/AppDelegate+RNCAsyncStorageDelegate.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "AppDelegate+RNCAsyncStorageDelegate.h" | ||
|
||
#import <RNCAsyncStorage/RNCAsyncStorage.h> | ||
|
||
@implementation AppDelegate (RNCAsyncStorageDelegate) | ||
tom-un marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
- (void)allKeys:(nonnull RNCAsyncStorageResultCallback)completion | ||
{ | ||
completion(self.memoryStorage.allKeys); | ||
} | ||
|
||
- (void)mergeValues:(nonnull NSArray<NSString *> *)values | ||
forKeys:(nonnull NSArray<NSString *> *)keys | ||
completion:(nonnull RNCAsyncStorageResultCallback)block | ||
{ | ||
[NSException raise:@"Unimplemented" | ||
format:@"%@ is unimplemented", NSStringFromSelector(_cmd)]; | ||
} | ||
|
||
- (void)removeAllValues:(nonnull RNCAsyncStorageCompletion)completion | ||
{ | ||
[self.memoryStorage removeAllObjects]; | ||
completion(nil); | ||
} | ||
|
||
- (void)removeValuesForKeys:(nonnull NSArray<NSString *> *)keys | ||
completion:(nonnull RNCAsyncStorageResultCallback)completion | ||
{ | ||
for (NSString *key in keys) { | ||
[self.memoryStorage removeObjectForKey:key]; | ||
} | ||
completion(@[]); | ||
} | ||
|
||
- (void)setValues:(nonnull NSArray<NSString *> *)values | ||
forKeys:(nonnull NSArray<NSString *> *)keys | ||
completion:(nonnull RNCAsyncStorageResultCallback)completion | ||
{ | ||
for (NSUInteger i = 0; i < values.count; ++i) { | ||
NSString *value = values[i]; | ||
NSString *key = keys[i]; | ||
[self.memoryStorage setObject:value forKey:key]; | ||
} | ||
completion(@[]); | ||
} | ||
|
||
- (void)valuesForKeys:(nonnull NSArray<NSString *> *)keys | ||
completion:(nonnull RNCAsyncStorageResultCallback)completion | ||
{ | ||
NSMutableArray *values = [NSMutableArray arrayWithCapacity:keys.count]; | ||
for (NSString *key in keys) { | ||
NSString *value = self.memoryStorage[key]; | ||
[values addObject:value == nil ? [NSNull null] : value]; | ||
} | ||
completion(values); | ||
} | ||
|
||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@class RCTBridge; | ||
|
||
@interface AppDelegate : NSObject <NSApplicationDelegate> | ||
|
||
@property (nonatomic, readonly) RCTBridge *bridge; | ||
@property (nonatomic, strong) NSMutableDictionary<NSString *, NSString *> *memoryStorage; | ||
|
||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#import "AppDelegate.h" | ||
|
||
#import "AppDelegate+RNCAsyncStorageDelegate.h" | ||
#import "RNCTestAsyncStorageDelegate.h" | ||
#import <RNCAsyncStorage/RNCAsyncStorage.h> | ||
|
||
#import <React/RCTBridge.h> | ||
#import <React/RCTBundleURLProvider.h> | ||
|
||
@interface AppDelegate () <RCTBridgeDelegate> | ||
|
||
@end | ||
|
||
@implementation AppDelegate { | ||
RNCTestAsyncStorageDelegate *_testDelegate; | ||
} | ||
|
||
- (void)awakeFromNib { | ||
[super awakeFromNib]; | ||
|
||
_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:nil]; | ||
|
||
_memoryStorage = [NSMutableDictionary dictionary]; | ||
} | ||
|
||
- (void)application:(NSApplication *)application openURLs:(NSArray<NSURL *> *)urls { | ||
NSURL *url = [urls firstObject]; | ||
|
||
if (![url.scheme isEqualToString:@"rnc-asyncstorage"]) { | ||
return; | ||
} | ||
|
||
if ([url.host isEqualToString:@"set-delegate"]) { | ||
if (_testDelegate == nil) { | ||
_testDelegate = [RNCTestAsyncStorageDelegate new]; | ||
} | ||
RNCAsyncStorage *asyncStorage = [_bridge moduleForClass:[RNCAsyncStorage class]]; | ||
asyncStorage.delegate = _testDelegate; | ||
} else if ([url.host isEqualToString:@"unset-delegate"]) { | ||
RNCAsyncStorage *asyncStorage = [_bridge moduleForClass:[RNCAsyncStorage class]]; | ||
asyncStorage.delegate = nil; | ||
} else if ([url.host isEqualToString:@"clear-all-data"]) { | ||
[RNCAsyncStorage clearAllData]; | ||
} | ||
} | ||
|
||
#pragma mark - RCTBridgeDelegate Methods | ||
|
||
- (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge { | ||
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"example/index" fallbackResource:@"main"]; // .jsbundle; | ||
} | ||
|
||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleURLTypes</key> | ||
<array> | ||
<dict> | ||
<key>CFBundleTypeRole</key> | ||
<string>Editor</string> | ||
<key>CFBundleURLName</key> | ||
<string>org.reactjs.native.example.AsyncStorageExample</string> | ||
<key>CFBundleURLSchemes</key> | ||
<array> | ||
<string>rnc-asyncstorage</string> | ||
</array> | ||
</dict> | ||
</array> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> | ||
<key>NSAppTransportSecurity</key> | ||
<dict> | ||
<key>NSAllowsArbitraryLoads</key> | ||
<true/> | ||
</dict> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2017 Facebook. All rights reserved.</string> | ||
tom-un marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
<key>NSMainStoryboardFile</key> | ||
<string>Main</string> | ||
<key>NSPrincipalClass</key> | ||
<string>NSApplication</string> | ||
</dict> | ||
</plist> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.