FlutterUITests.m 3.57 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import XCTest;

@interface FlutterUITests : XCTestCase
@end

@implementation FlutterUITests

- (void)setUp {
    self.continueAfterFailure = NO;
}

- (void)testFullScreenColdPop {
    XCUIApplication *app = [[XCUIApplication alloc] init];
    [app launch];

    [app.buttons[@"Full Screen (Cold)"] tap];

22
    XCTAssertTrue([app.staticTexts[@"Button tapped 0 times."] waitForExistenceWithTimeout:60.0]);
23
    [app.otherElements[@"Increment via Flutter"] tap];
24
    XCTAssertTrue([app.staticTexts[@"Button tapped 1 time."] waitForExistenceWithTimeout:60.0]);
25 26 27

    // Back navigation.
    [app.buttons[@"POP"] tap];
28
    XCTAssertTrue([app.navigationBars[@"Flutter iOS Demos Home"] waitForExistenceWithTimeout:60.0]);
29 30 31 32 33 34 35 36
}

- (void)testFullScreenWarm {
    XCUIApplication *app = [[XCUIApplication alloc] init];
    [app launch];

    [app.buttons[@"Full Screen (Warm)"] tap];

37
    XCTAssertTrue([app.staticTexts[@"Button tapped 0 times."] waitForExistenceWithTimeout:60.0]);
38
    [app.otherElements[@"Increment via Flutter"] tap];
39
    XCTAssertTrue([app.staticTexts[@"Button tapped 1 time."] waitForExistenceWithTimeout:60.0]);
40 41 42

    // Back navigation.
    [app.buttons[@"POP"] tap];
43
    XCTAssertTrue([app.navigationBars[@"Flutter iOS Demos Home"] waitForExistenceWithTimeout:60.0]);
44 45 46 47 48 49 50 51
}

- (void)testFlutterViewWarm {
    XCUIApplication *app = [[XCUIApplication alloc] init];
    [app launch];

    [app.buttons[@"Flutter View (Warm)"] tap];

52
    XCTAssertTrue([app.staticTexts[@"Button tapped 0 times."] waitForExistenceWithTimeout:60.0]);
53
    [app.otherElements[@"Increment via Flutter"] tap];
54
    XCTAssertTrue([app.staticTexts[@"Button tapped 1 time."] waitForExistenceWithTimeout:60.0]);
55 56 57

    // Back navigation.
    [app.buttons[@"POP"] tap];
58
    XCTAssertTrue([app.navigationBars[@"Flutter iOS Demos Home"] waitForExistenceWithTimeout:60.0]);
59 60 61 62 63 64 65 66
}

- (void)testHybridViewWarm {
    XCUIApplication *app = [[XCUIApplication alloc] init];
    [app launch];

    [app.buttons[@"Hybrid View (Warm)"] tap];

67
    XCTAssertTrue([app.staticTexts[@"Flutter button tapped 0 times."] waitForExistenceWithTimeout:60.0]);
68
    XCTAssertTrue(app.staticTexts[@"Platform button tapped 0 times."].exists);
69 70

    [app.otherElements[@"Increment via Flutter"] tap];
71
    XCTAssertTrue([app.staticTexts[@"Flutter button tapped 1 time."] waitForExistenceWithTimeout:60.0]);
72
    XCTAssertTrue(app.staticTexts[@"Platform button tapped 0 times."].exists);
73 74

    [app.buttons[@"Increment via iOS"] tap];
75
    XCTAssertTrue([app.staticTexts[@"Flutter button tapped 1 time."] waitForExistenceWithTimeout:60.0]);
76
    XCTAssertTrue(app.staticTexts[@"Platform button tapped 1 time."].exists);
77 78 79

    // Back navigation.
    [app.navigationBars[@"Hybrid Flutter/Native"].buttons[@"Flutter iOS Demos Home"] tap];
80
    XCTAssertTrue([app.navigationBars[@"Flutter iOS Demos Home"] waitForExistenceWithTimeout:60.0]);
81 82 83 84 85 86 87 88 89
}

- (void)testDualCold {
    XCUIApplication *app = [[XCUIApplication alloc] init];
    [app launch];

    [app.buttons[@"Dual Flutter View (Cold)"] tap];

    // There are two marquees.
90 91
    XCTAssertTrue([app.staticTexts[@"This is Marquee"] waitForExistenceWithTimeout:60.0]);
    XCTAssertEqual([app.staticTexts matchingType:XCUIElementTypeStaticText identifier:@"This is Marquee"].count, 2);
92 93 94

    // Back navigation.
    [app.navigationBars[@"Dual Flutter Views"].buttons[@"Flutter iOS Demos Home"] tap];
95
    XCTAssertTrue([app.navigationBars[@"Flutter iOS Demos Home"] waitForExistenceWithTimeout:60.0]);
96 97 98
}

@end