Skip to content

Commit

Permalink
Merge pull request #1 from sfrank87/CB-8467_provide_hide_method_to_hi…
Browse files Browse the repository at this point in the history
…de_browser_window

removed duplicate hide method in ios source and add jasmine test cases

 This closes #101
  • Loading branch information
herrevilkitten authored and jcesarmobile committed Oct 19, 2016
2 parents df8bcaf + 20c21f3 commit e853399
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
24 changes: 0 additions & 24 deletions src/ios/CDVInAppBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -267,30 +267,6 @@ - (void)hide:(CDVInvokedUrlCommand*)command
});
}

- (void)hide:(CDVInvokedUrlCommand*)command
{
if (self.inAppBrowserViewController == nil) {
NSLog(@"Tried to hide IAB after it was closed.");
return;


}
if (_previousStatusBarStyle == -1) {
NSLog(@"Tried to hide IAB while already hidden");
return;
}

_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;

// Run later to avoid the "took a long time" log message.
dispatch_async(dispatch_get_main_queue(), ^{
if (self.inAppBrowserViewController != nil) {
_previousStatusBarStyle = -1;
[self.viewController dismissViewControllerAnimated:YES completion:nil];
}
});
}

- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
{
NSURLRequest* request = [NSURLRequest requestWithURL:url];
Expand Down
11 changes: 10 additions & 1 deletion tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ exports.defineAutoTests = function () {
expect(iabInstance.removeEventListener).toEqual(jasmine.any(Function));
expect(iabInstance.close).toEqual(jasmine.any(Function));
expect(iabInstance.show).toEqual(jasmine.any(Function));
expect(iabInstance.hide).toEqual(jasmine.any(Function));
expect(iabInstance.executeScript).toEqual(jasmine.any(Function));
expect(iabInstance.insertCSS).toEqual(jasmine.any(Function));
});
Expand Down Expand Up @@ -421,7 +422,9 @@ exports.defineManualTests = function (contentEl, createActionButton) {
'<p/> <div id="closeHidden"></div>' +
'Expected result: no output. But click on "show hidden" again and nothing should be shown.' +
'<p/> <div id="openHiddenShow"></div>' +
'Expected result: open successfully in InAppBrowser to https://www.google.co.uk';
'Expected result: open successfully in InAppBrowser to https://www.google.co.uk' +
'<p/> <div id="openVisibleAndHide"></div>' +
'Expected result: open successfully in InAppBrowser to https://www.google.co.uk. Hide after 2 seconds';

var clearing_cache_tests = '<h1>Clearing Cache</h1>' +
'<div id="openClearCache"></div>' +
Expand Down Expand Up @@ -620,6 +623,12 @@ exports.defineManualTests = function (contentEl, createActionButton) {
createActionButton('google.co.uk Not Hidden', function () {
openHidden('https://www.google.co.uk', false);
}, 'openHiddenShow');
createActionButton('google.co.uk shown for 2 seconds than hidden', function () {
var iab = doOpen('https://www.google.co.uk/', 'random_sting');
setTimeout(function () {
iab.hide();
}, 2000);
}, 'openVisibleAndHide');

//Clearing cache
createActionButton('Clear Browser Cache', function () {
Expand Down

0 comments on commit e853399

Please sign in to comment.