Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: base/test/test_listener_ios.mm

Issue 12047058: Add NSLogTestEventListener to support running tests on iOS 6 devices. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: one arg per line in declaration or definitions Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/test/test_listener_ios.h ('k') | base/test/test_suite.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "base/test/test_listener_ios.h" 5 #include "base/test/test_listener_ios.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/ios/ios_util.h"
9 #include "base/mac/scoped_nsautorelease_pool.h" 10 #include "base/mac/scoped_nsautorelease_pool.h"
11 #include "base/test/nslog_test_event_listener.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 13
12 // The iOS watchdog timer will kill an app that doesn't spin the main event 14 // The iOS watchdog timer will kill an app that doesn't spin the main event
13 // loop often enough. This uses a Gtest TestEventListener to spin the current 15 // loop often enough. This uses a Gtest TestEventListener to spin the current
14 // loop after each test finishes. However, if any individual test takes too 16 // loop after each test finishes. However, if any individual test takes too
15 // long, it is still possible that the app will get killed. 17 // long, it is still possible that the app will get killed.
16 18
17 namespace { 19 namespace {
18 20
19 class IOSRunLoopListener : public testing::EmptyTestEventListener { 21 class IOSRunLoopListener : public testing::EmptyTestEventListener {
(...skipping 14 matching lines...) Expand all
34 36
35 namespace base { 37 namespace base {
36 namespace test_listener_ios { 38 namespace test_listener_ios {
37 39
38 void RegisterTestEndListener() { 40 void RegisterTestEndListener() {
39 testing::TestEventListeners& listeners = 41 testing::TestEventListeners& listeners =
40 testing::UnitTest::GetInstance()->listeners(); 42 testing::UnitTest::GetInstance()->listeners();
41 listeners.Append(new IOSRunLoopListener); 43 listeners.Append(new IOSRunLoopListener);
42 } 44 }
43 45
46 // Only add the NSLogTestEventListener when running on a device with iOS 6 or
47 // later.
48 void RegisterNSLogListenerIfNecessary() {
49 #if !TARGET_IPHONE_SIMULATOR
50 NSLog(@"Running on a device");
51 if (ios::IsRunningOnIOS6OrLater()) {
52 testing::TestEventListeners& listeners =
53 testing::UnitTest::GetInstance()->listeners();
54 listeners.Append(new NSLogTestEventListener);
55 }
56 #endif
57 }
58
44 } // namespace test_listener_ios 59 } // namespace test_listener_ios
45 } // namespace base 60 } // namespace base
OLDNEW
« no previous file with comments | « base/test/test_listener_ios.h ('k') | base/test/test_suite.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698