Changeset 206827 in webkit


Ignore:
Timestamp:
Oct 5, 2016 1:46:15 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Add MobileMiniBrowser tests for control center and looping fullscreen.
https://bugs.webkit.org/show_bug.cgi?id=162748

Patch by Jeremy Jones <jeremyj@apple.com> on 2016-10-05
Reviewed by Jer Noble.

Refactor existing MobileMiniBrowserTests and add new tests for

  • fullscreen rotation
  • fullscreen looping (failing)
  • control center interruption (failing)
  • MobileMiniBrowser/MobileMiniBrowser.xcodeproj/project.pbxproj:
  • MobileMiniBrowser/MobileMiniBrowserFramework/Resources/looping2s.html: Added.
  • MobileMiniBrowser/MobileMiniBrowserFramework/test2s.mp4: Added.
  • MobileMiniBrowser/MobileMiniBrowserUITests/MobileMiniBrowserUITests.m:

(-[MobileMiniBrowserUITests setUp]):
(-[MobileMiniBrowserUITests waitToTapButtonNamed:forApp:]):
(-[MobileMiniBrowserUITests loadURL:]):
(-[MobileMiniBrowserUITests requireMinFPS:sampleDurationSeconds:message:]):
(-[MobileMiniBrowserUITests ensureFullscreenControls]):
(-[MobileMiniBrowserUITests timeForTimeString:]):
(-[MobileMiniBrowserUITests testBasicVideoPlayback]):
(-[MobileMiniBrowserUITests testBasicVideoFullscreen]):
(-[MobileMiniBrowserUITests testVideoFullscreenAndRotationAnimation]):
(-[MobileMiniBrowserUITests testVideoFullscreenControlCenter]):
(-[MobileMiniBrowserUITests testLoopingFullscreenLockup]):

Location:
trunk/Tools
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r206819 r206827  
     12016-10-05  Jeremy Jones  <jeremyj@apple.com>
     2
     3        Add MobileMiniBrowser tests for control center and looping fullscreen.
     4        https://bugs.webkit.org/show_bug.cgi?id=162748
     5
     6        Reviewed by Jer Noble.
     7
     8        Refactor existing MobileMiniBrowserTests and add new tests for
     9        - fullscreen rotation
     10        - fullscreen looping (failing)
     11        - control center interruption (failing)
     12
     13        * MobileMiniBrowser/MobileMiniBrowser.xcodeproj/project.pbxproj:
     14        * MobileMiniBrowser/MobileMiniBrowserFramework/Resources/looping2s.html: Added.
     15        * MobileMiniBrowser/MobileMiniBrowserFramework/test2s.mp4: Added.
     16        * MobileMiniBrowser/MobileMiniBrowserUITests/MobileMiniBrowserUITests.m:
     17        (-[MobileMiniBrowserUITests setUp]):
     18        (-[MobileMiniBrowserUITests waitToTapButtonNamed:forApp:]):
     19        (-[MobileMiniBrowserUITests loadURL:]):
     20        (-[MobileMiniBrowserUITests requireMinFPS:sampleDurationSeconds:message:]):
     21        (-[MobileMiniBrowserUITests ensureFullscreenControls]):
     22        (-[MobileMiniBrowserUITests timeForTimeString:]):
     23        (-[MobileMiniBrowserUITests testBasicVideoPlayback]):
     24        (-[MobileMiniBrowserUITests testBasicVideoFullscreen]):
     25        (-[MobileMiniBrowserUITests testVideoFullscreenAndRotationAnimation]):
     26        (-[MobileMiniBrowserUITests testVideoFullscreenControlCenter]):
     27        (-[MobileMiniBrowserUITests testLoopingFullscreenLockup]):
     28
    1292016-10-05  Alex Christensen  <achristensen@webkit.org>
    230
  • trunk/Tools/MobileMiniBrowser/MobileMiniBrowser.xcodeproj/project.pbxproj

    r205353 r206827  
    88
    99/* Begin PBXBuildFile section */
     10                3F0B439B1D908D0C00D186B5 /* looping2s.html in Resources */ = {isa = PBXBuildFile; fileRef = 3F0B439A1D908D0C00D186B5 /* looping2s.html */; };
     11                3F0B439D1D908DE700D186B5 /* test2s.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 3F0B439C1D908DE700D186B5 /* test2s.mp4 */; };
    1012                CD1DAF971D709E3600017CF0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CD1DAF961D709E3600017CF0 /* main.m */; };
    1113                CD1DAFA51D709E3600017CF0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CD1DAFA31D709E3600017CF0 /* LaunchScreen.storyboard */; };
     
    6466
    6567/* Begin PBXFileReference section */
     68                3F0B439A1D908D0C00D186B5 /* looping2s.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = looping2s.html; path = Resources/looping2s.html; sourceTree = "<group>"; };
     69                3F0B439C1D908DE700D186B5 /* test2s.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = test2s.mp4; sourceTree = "<group>"; };
    6670                CD1DAF921D709E3600017CF0 /* MobileMiniBrowser.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MobileMiniBrowser.app; sourceTree = BUILT_PRODUCTS_DIR; };
    6771                CD1DAF961D709E3600017CF0 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
     
    201205                        children = (
    202206                                CDA985151D76477900EBC399 /* test.mp4 */,
     207                                3F0B439C1D908DE700D186B5 /* test2s.mp4 */,
    203208                                CDA985131D76474100EBC399 /* index.html */,
    204209                                CDA985171D7647CD00EBC399 /* looping.html */,
     210                                3F0B439A1D908D0C00D186B5 /* looping2s.html */,
    205211                        );
    206212                        name = Resources;
     
    346352                                CDA9851A1D76483400EBC399 /* index.html in Resources */,
    347353                                CD498B521D763D8800681FA7 /* Assets.xcassets in Resources */,
     354                                3F0B439B1D908D0C00D186B5 /* looping2s.html in Resources */,
    348355                                CD498B511D763D7F00681FA7 /* Main.storyboard in Resources */,
    349356                                CDA9851B1D76483400EBC399 /* looping.html in Resources */,
    350357                                CD498B531D763D9300681FA7 /* Info.plist in Resources */,
    351358                                CDA985191D76483400EBC399 /* test.mp4 in Resources */,
     359                                3F0B439D1D908DE700D186B5 /* test2s.mp4 in Resources */,
    352360                        );
    353361                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Tools/MobileMiniBrowser/MobileMiniBrowserUITests/MobileMiniBrowserUITests.m

    r205353 r206827  
    2424 */
    2525
     26#import <QuartzCore/CARenderServer.h>
    2627#import <XCTest/XCTest.h>
    2728#import <XCTest/XCUIRemote.h>
    2829
     30@interface XCUIApplication ()
     31-(instancetype)initPrivateWithPath:(NSString *)path bundleID:(NSString *)bundleID;
     32@end
     33
    2934@interface MobileMiniBrowserUITests : XCTestCase
    3035
    3136@end
    3237
    33 @implementation MobileMiniBrowserUITests
     38@implementation MobileMiniBrowserUITests {
     39    XCUIApplication *app;
     40    NSPredicate *exists;
     41}
    3442
    3543- (void)setUp
     
    3947    self.continueAfterFailure = NO;
    4048
    41     XCUIApplication *app = [[XCUIApplication alloc] init];
     49    exists = [NSPredicate predicateWithFormat:@"exists == 1"];
     50    app = [[XCUIApplication alloc] init];
    4251    [app launch];
    4352}
     
    4857}
    4958
    50 - (void)testBasicVideoPlayback
    51 {
    52     XCUIApplication *app = [[XCUIApplication alloc] init];
    53     NSPredicate *exists = [NSPredicate predicateWithFormat:@"exists == 1"];
    54 
     59- (void)waitToTapButtonNamed:(NSString *)name forApp:(XCUIApplication *)targetApp {
     60    XCUIElement *button = targetApp.buttons[name];
     61    [self expectationForPredicate:exists evaluatedWithObject:button handler:nil];
     62    [self waitForExpectationsWithTimeout:5.0 handler:nil];
     63    [button tap];
     64}
     65
     66- (void)loadURL:(NSString *)url {
    5567    XCUIElement *urlField = app.textFields[@"URL Field"];
    5668    [self expectationForPredicate:exists evaluatedWithObject:urlField handler:nil];
    5769    [self waitForExpectationsWithTimeout:5.0 handler:nil];
    5870    [urlField tap];
    59 
     71   
    6072    XCUIElement *clearButton = urlField.buttons[@"Clear text"];
    6173    if (clearButton.exists)
    6274        [clearButton tap];
    63     [urlField typeText:@"bundle:/looping.html"];
     75    [urlField typeText:url];
    6476    [app.buttons[@"Go To URL"] tap];
    65 
    66     XCUIElement *startPlayback = app.buttons[@"Start Playback"];
    67     [self expectationForPredicate:exists evaluatedWithObject:startPlayback handler:nil];
    68     [self waitForExpectationsWithTimeout:5.0 handler:nil];
    69     [startPlayback tap];
     77}
     78
     79- (void)requireMinFPS:(NSTimeInterval)minFPS sampleDurationSeconds:(NSTimeInterval)sampleSeconds message:(NSString *)message {
     80    NSTimeInterval startTime = [NSDate timeIntervalSinceReferenceDate];
     81    uint32_t initialFrameCount = CARenderServerGetFrameCounter(0);
     82    usleep(sampleSeconds*1000000);
     83    uint32_t finalFrameCount = CARenderServerGetFrameCounter(0);
     84    NSTimeInterval endTime = [NSDate timeIntervalSinceReferenceDate];
     85    NSTimeInterval framesPerSecond = (finalFrameCount - initialFrameCount) / (endTime - startTime);
     86   
     87    XCTAssert(framesPerSecond > 30, @"framesPerSecond < %f: %@", framesPerSecond, message);
     88}
     89
     90- (void)ensureFullscreenControls {
     91    if (!app.buttons[@"Done"].exists) {
     92        XCUIElement* window = [app.windows allElementsBoundByIndex][0];
     93        XCUICoordinate* center = [window coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.5)];
     94        [center tap];
     95    }
     96}
     97
     98- (NSTimeInterval)timeForTimeString:(NSString *)time {
     99    NSArray *components = [time componentsSeparatedByString:@":"];
     100    if (components.count == 3)
     101        return [components[0] doubleValue]*60*60 + [components[1] doubleValue]*60 + [components[2] doubleValue];
     102
     103    return [components[0] doubleValue]*60 + [components[1] doubleValue];
     104}
     105
     106- (void)testBasicVideoPlayback
     107{
     108    [self loadURL:@"bundle:/looping.html"];
     109    [self waitToTapButtonNamed:@"Start Playback" forApp:app];
    70110
    71111    UIUserInterfaceIdiom idiom = UI_USER_INTERFACE_IDIOM();
    72112    if (idiom == UIUserInterfaceIdiomPhone) {
    73         XCUIElement *pauseButton = app.buttons[@"PauseButton"];
    74         [self expectationForPredicate:exists evaluatedWithObject:pauseButton handler:nil];
    75         [self waitForExpectationsWithTimeout:5.0 handler:nil];
    76         [pauseButton tap];
    77 
    78         XCUIElement *doneButton = app.buttons[@"Done"];
    79         [self expectationForPredicate:exists evaluatedWithObject:doneButton handler:nil];
    80         [self waitForExpectationsWithTimeout:5.0 handler:nil];
    81         [doneButton tap];
    82     } else if (idiom == UIUserInterfaceIdiomPad) {
    83         XCUIElement *pauseButton = app.buttons[@"Pause"];
    84         [self expectationForPredicate:exists evaluatedWithObject:pauseButton handler:nil];
    85         [self waitForExpectationsWithTimeout:5.0 handler:nil];
    86         [pauseButton tap];
    87     }
     113        [self waitToTapButtonNamed:@"PauseButton" forApp:app];
     114        [self waitToTapButtonNamed:@"Done" forApp:app];
     115    } else if (idiom == UIUserInterfaceIdiomPad)
     116        [self waitToTapButtonNamed:@"Pause" forApp:app];
     117}
     118
     119- (void)testBasicVideoFullscreen
     120{
     121    [self loadURL:@"bundle:/looping.html"];
     122    [self waitToTapButtonNamed:@"Start Playback" forApp:app];
     123   
     124    UIUserInterfaceIdiom idiom = UI_USER_INTERFACE_IDIOM();
     125    if (idiom == UIUserInterfaceIdiomPad)
     126        [self waitToTapButtonNamed:@"Display Full Screen" forApp:app];
     127   
     128    [self waitToTapButtonNamed:@"PauseButton" forApp:app];
     129    [self waitToTapButtonNamed:@"Done" forApp:app];
     130}
     131
     132- (void)testVideoFullscreenAndRotationAnimation
     133{
     134    XCUIDevice *device = [XCUIDevice sharedDevice];
     135    device.orientation = UIDeviceOrientationPortrait;
     136   
     137    [self loadURL:@"bundle:/looping.html"];
     138    [self waitToTapButtonNamed:@"Start Playback" forApp:app];
     139   
     140    UIUserInterfaceIdiom idiom = UI_USER_INTERFACE_IDIOM();
     141    if (idiom == UIUserInterfaceIdiomPad)
     142        [self waitToTapButtonNamed:@"Display Full Screen" forApp:app];
     143   
     144    [self requireMinFPS:30 sampleDurationSeconds:1 message:@"Framerate during enter fullscreen animation."];
     145    device.orientation = UIDeviceOrientationLandscapeLeft;
     146    [self requireMinFPS:30 sampleDurationSeconds:1 message:@"Framerate during rotation animation."];
     147    [self waitToTapButtonNamed:@"Done" forApp:app];
     148    [self requireMinFPS:30 sampleDurationSeconds:1 message:@"Framerate during exit fullscreen  animation."];
     149}
     150
     151- (void)testVideoFullscreenControlCenter
     152{
     153    [self loadURL:@"bundle:/looping.html"];
     154    [self waitToTapButtonNamed:@"Start Playback" forApp:app];
     155   
     156    UIUserInterfaceIdiom idiom = UI_USER_INTERFACE_IDIOM();
     157    if (idiom == UIUserInterfaceIdiomPad)
     158        [self waitToTapButtonNamed:@"Display Full Screen" forApp:app];
     159   
     160    XCUIElement* window = [app.windows allElementsBoundByIndex][0];
     161    XCUICoordinate* top = [window coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.5)];
     162    XCUICoordinate* bottom = [window coordinateWithNormalizedOffset:CGVectorMake(0.5, 1)];
     163    [bottom pressForDuration:0 thenDragToCoordinate:top];
     164    [bottom pressForDuration:0 thenDragToCoordinate:top];
     165   
     166    XCTAssert(app.buttons[@"PlayButton"].exists, @"Control center should have interrupted");
     167   
     168    XCUIApplication* springboard = [[XCUIApplication alloc] initPrivateWithPath:nil bundleID:@"com.apple.springboard"];
     169    XCUICoordinate* right = [window coordinateWithNormalizedOffset:CGVectorMake(1, 0.9)];
     170    XCUICoordinate* left = [window coordinateWithNormalizedOffset:CGVectorMake(0, 0.9)];
     171
     172    if (springboard.switches[@"Continue"].exists)
     173        [springboard.switches[@"Continue"] tap];
     174   
     175    if (springboard.switches[@"Airplane Mode"].exists)
     176        [right pressForDuration:0 thenDragToCoordinate:left];
     177
     178    XCTAssert(springboard.buttons[@"Play"].exists, @"Control center should have interrupted");
     179   
     180    NSString* appElapsedString = [app.staticTexts elementBoundByIndex:0].label;
     181    NSTimeInterval appElapsed = [self timeForTimeString:appElapsedString];
     182   
     183    NSString* controlCenterTrackString = springboard.otherElements[@"Track position"].value;
     184    NSArray* components = [controlCenterTrackString componentsSeparatedByString:@" of "];
     185    NSTimeInterval controlCenterElapsed = [self timeForTimeString:components[0]];
     186   
     187    XCTAssert(appElapsed == round(controlCenterElapsed), "Elapsed times match");
     188}
     189
     190// rdar://problem/27685077
     191- (void)testLoopingFullscreenLockup
     192{
     193    [self loadURL:@"bundle:/looping2s.html"];
     194   
     195    XCUIElement* window = [app.windows allElementsBoundByIndex][0];
     196    XCUICoordinate* gifLoc = [window coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.75)];
     197    [gifLoc pressForDuration:0];
     198   
     199    [self waitToTapButtonNamed:@"Start Playback" forApp:app];
     200   
     201    [self waitToTapButtonNamed:@"ExitFullScreenButton" forApp:app];
     202    [self waitToTapButtonNamed:@"ExitFullScreenButton" forApp:app];
     203    [self waitToTapButtonNamed:@"ExitFullScreenButton" forApp:app];
     204    [self waitToTapButtonNamed:@"ExitFullScreenButton" forApp:app];
     205    [self waitToTapButtonNamed:@"ExitFullScreenButton" forApp:app];
    88206}
    89207
Note: See TracChangeset for help on using the changeset viewer.