blob: 415d0c07c74d853a500f15ad351c1373c97f9b72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
//
// GTMCodeCovereageApp.m
//
// Copyright 2013 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
//
// This code exists for doing code coverage with Xcode and iOS.
// Please read through https://code.google.com/p/coverstory/wiki/UsingCoverstory
// for details.
// This file should be conditionally compiled into your application bundle
// or test rig when you want to do code coverage.
#import "GTMCodeCoverageApp.h"
// Add GTM_IS_COVERAGE_BUILD to your GCC_PREPROCESSOR_DEFINITIONS for the
// Xcode Configuration that wants CodeCoverage support.
#if GTM_IS_COVERAGE_BUILD
extern void __gcov_flush();
@implementation UIApplication(GTMCodeCoverage)
- (void)gtm_gcov_flush {
__gcov_flush();
}
#if GTM_USING_XCTEST
+ (void)load {
// Using defines and strings so that we don't have to link in
// XCTest here.
// Must set defaults here. If we set them in XCTest we are too late
// for the observer registration.
// See the documentation of XCTestObserverClassKey for why we set this key.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *observers = [defaults stringForKey:GTMXCTestObserverClassKey];
NSString *className = @"GTMCodeCoverageTests";
if (observers == nil) {
observers = GTMXCTestLogClass;
}
observers = [NSString stringWithFormat:@"%@,%@", observers, className];
[defaults setValue:observers forKey:GTMXCTestObserverClassKey];
}
#endif // GTM_USING_XCTEST
@end
#endif // GTM_IS_COVERAGE_BUILD
|