OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #import "ios/web/shell/test/earl_grey/shell_base_test_case.h" | |
6 | |
7 #import <EarlGrey/EarlGrey.h> | |
8 | |
9 #import "ios/web/public/test/http_server.h" | |
10 #import "ios/web/shell/test/earl_grey/shell_matchers.h" | |
11 | |
12 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
13 #error "This file requires ARC support." | |
14 #endif | |
15 | |
16 using web::test::HttpServer; | |
17 using web::WebViewContainingText; | |
18 | |
19 @implementation ShellBaseTestCase | |
20 | |
21 // Overrides |testInvocations| to skip all tests if a system alert view is | |
22 // shown, since this isn't a case a user would encounter (i.e. they would | |
23 // dismiss the alert first). | |
24 + (NSArray*)testInvocations { | |
25 // TODO(crbug.com/654085): Simply skipping all tests isn't the best way to | |
26 // handle this, it would be better to have something that is more obvious | |
27 // on the bots that this is wrong, without making it look like test flake. | |
28 NSError* error = nil; | |
29 [[EarlGrey selectElementWithMatcher:grey_systemAlertViewShown()] | |
30 assertWithMatcher:grey_nil() | |
31 error:&error]; | |
32 if (error != nil) { | |
33 NSLog(@"System alert view is present, so skipping all tests!"); | |
34 return @[]; | |
35 } | |
36 return [super testInvocations]; | |
37 } | |
38 | |
39 // Set up called once for the class. | |
40 + (void)setUp { | |
41 [super setUp]; | |
42 HttpServer::GetSharedInstance().StartOrDie(); | |
43 } | |
44 | |
45 // Tear down called once for the class. | |
46 + (void)tearDown { | |
47 HttpServer::GetSharedInstance().Stop(); | |
48 [super tearDown]; | |
49 } | |
50 | |
51 // Tear down called after each test. | |
52 - (void)tearDown { | |
53 HttpServer::GetSharedInstance().RemoveAllResponseProviders(); | |
54 [super tearDown]; | |
55 } | |
56 | |
57 @end | |
OLD | NEW |