Vojta Bartos abf1438f54 fixing shake to open Dev Menu only work once
Summary:
Fixing issues https://github.com/facebook/react-native/issues/10588

This bug has been introduced during refactoring UIActionSheet to UIAlertController d368ebfab2 (diff-f78a84ff95f2bcee5a70d3accb504528)

**Test plan**

- shake to open DevMenu, choose random menu item, it should close DevMenu and after another shaking it should open again
Closes https://github.com/facebook/react-native/pull/10676

Differential Revision: D4168254

Pulled By: javache

fbshipit-source-id: 6e2935b765053a2b55809af357d2b6ea03e04e8b
2016-11-29 13:43:31 -08:00

70 lines
1.9 KiB
Objective-C

/**
* The examples provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#import <XCTest/XCTest.h>
#import "RCTBridge.h"
#import "RCTDevMenu.h"
typedef void(^RCTDevMenuAlertActionHandler)(UIAlertAction *action);
@interface RCTDevMenu ()
- (RCTDevMenuAlertActionHandler)alertActionHandlerForDevItem:(RCTDevMenuItem *)item;
@end
@interface RCTDevMenuTests : XCTestCase
@end
@implementation RCTDevMenuTests
{
RCTBridge *_bridge;
}
- (void)setUp
{
[super setUp];
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
_bridge = [[RCTBridge alloc] initWithBundleURL:[bundle URLForResource:@"TestBundle" withExtension:@"js"]
moduleProvider:nil
launchOptions:nil];
}
- (void)testShowCreatingActionSheet
{
XCTAssertFalse([_bridge.devMenu isActionSheetShown]);
[_bridge.devMenu show];
XCTAssertTrue([_bridge.devMenu isActionSheetShown]);
}
- (void)testClosingActionSheetAfterAction
{
for (RCTDevMenuItem *item in _bridge.devMenu.presentedItems) {
RCTDevMenuAlertActionHandler handler = [_bridge.devMenu alertActionHandlerForDevItem:item];
XCTAssertTrue([_bridge.devMenu isActionSheetShown]);
handler(nil);
XCTAssertFalse([_bridge.devMenu isActionSheetShown]);
[_bridge.devMenu show];
XCTAssertTrue([_bridge.devMenu isActionSheetShown]);
}
}
@end