| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/showcase/test/showcase_test_case.h" | 5 #import "ios/showcase/test/showcase_test_case.h" |
| 6 | 6 |
| 7 #import <EarlGrey/EarlGrey.h> | 7 #import <EarlGrey/EarlGrey.h> |
| 8 | 8 |
| 9 #import "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/sys_string_conversions.h" |
| 11 #include "testing/coverage_util_ios.h" |
| 10 | 12 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) | 13 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." | 14 #error "This file requires ARC support." |
| 13 #endif | 15 #endif |
| 14 | 16 |
| 15 @implementation ShowcaseTestCase | 17 @implementation ShowcaseTestCase |
| 16 | 18 |
| 19 + (void)setUp { |
| 20 // Writes the profraw file to the Documents directory, where the app has |
| 21 // write rights. |
| 22 // NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, |
| 23 // NSUserDomainMask, YES); |
| 24 // NSString *documentsDirectory = [paths firstObject]; |
| 25 // NSString *fileName = |
| 26 // [documentsDirectory stringByAppendingPathComponent:@"default.profraw"]; |
| 27 coverage_util::SetupCodeCoverageIfNecessary( |
| 28 base::SysNSStringToUTF8(@"/Users/lpromero/Developer/bling/src/out/" |
| 29 @"Debug-iphonesimulator/coverage.profraw")); |
| 30 } |
| 31 |
| 17 // Overrides testInvocations so the set of tests run can be modified, as | 32 // Overrides testInvocations so the set of tests run can be modified, as |
| 18 // necessary. | 33 // necessary. |
| 19 + (NSArray*)testInvocations { | 34 + (NSArray*)testInvocations { |
| 20 NSError* error = nil; | 35 NSError* error = nil; |
| 21 [[EarlGrey selectElementWithMatcher:grey_systemAlertViewShown()] | 36 [[EarlGrey selectElementWithMatcher:grey_systemAlertViewShown()] |
| 22 assertWithMatcher:grey_nil() | 37 assertWithMatcher:grey_nil() |
| 23 error:&error]; | 38 error:&error]; |
| 24 if (error != nil) { | 39 if (error != nil) { |
| 25 LOG(ERROR) << "System alert view is present, so skipping all tests."; | 40 LOG(ERROR) << "System alert view is present, so skipping all tests."; |
| 26 return @[]; | 41 return @[]; |
| 27 } | 42 } |
| 28 return [super testInvocations]; | 43 return [super testInvocations]; |
| 29 } | 44 } |
| 30 | 45 |
| 31 @end | 46 @end |
| OLD | NEW |