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

Side by Side Diff: base/mac/scoped_sending_event_unittest.mm

Issue 656293003: [Mac] Do not initialize the MockCrApplication in base::TestSuite. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready for review Created 6 years, 2 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 | « no previous file | base/test/test_suite.cc » ('j') | ui/app_list/test/run_all_unittests.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/mac/scoped_sending_event.h" 5 #import "base/mac/scoped_sending_event.h"
6 6
7 #import <Foundation/Foundation.h>
8
9 #include "base/mac/scoped_nsobject.h"
7 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
8 11
Mark Mentovai 2014/10/17 19:44:58 :)
12 @interface ScopedSendingEventTestCrApp : NSObject <CrAppControlProtocol> {
13 @private
14 BOOL handlingSendEvent_;
15 }
16 @property(nonatomic, assign, getter=isHandlingSendEvent) BOOL handlingSendEvent;
17 @end
18
19 @implementation ScopedSendingEventTestCrApp
20 @synthesize handlingSendEvent = handlingSendEvent_;
21 @end
22
9 namespace { 23 namespace {
10 24
25 class ScopedSendingEventTest : public testing::Test {
26 public:
27 ScopedSendingEventTest() : app_([[ScopedSendingEventTestCrApp alloc] init]) {
28 NSApp = app_.get();
29 }
30 virtual ~ScopedSendingEventTest() {
31 NSApp = nil;
32 }
33
34 private:
35 base::scoped_nsobject<ScopedSendingEventTestCrApp> app_;
36 };
37
11 // Sets the flag within scope, resets when leaving scope. 38 // Sets the flag within scope, resets when leaving scope.
12 TEST(ScopedSendingEventTest, SetHandlingSendEvent) { 39 TEST_F(ScopedSendingEventTest, SetHandlingSendEvent) {
13 id<CrAppProtocol> app = NSApp; 40 id<CrAppProtocol> app = NSApp;
14 EXPECT_FALSE([app isHandlingSendEvent]); 41 EXPECT_FALSE([app isHandlingSendEvent]);
15 { 42 {
16 base::mac::ScopedSendingEvent is_handling_send_event; 43 base::mac::ScopedSendingEvent is_handling_send_event;
17 EXPECT_TRUE([app isHandlingSendEvent]); 44 EXPECT_TRUE([app isHandlingSendEvent]);
18 } 45 }
19 EXPECT_FALSE([app isHandlingSendEvent]); 46 EXPECT_FALSE([app isHandlingSendEvent]);
20 } 47 }
21 48
22 // Nested call restores previous value rather than resetting flag. 49 // Nested call restores previous value rather than resetting flag.
23 TEST(ScopedSendingEventTest, NestedSetHandlingSendEvent) { 50 TEST_F(ScopedSendingEventTest, NestedSetHandlingSendEvent) {
24 id<CrAppProtocol> app = NSApp; 51 id<CrAppProtocol> app = NSApp;
25 EXPECT_FALSE([app isHandlingSendEvent]); 52 EXPECT_FALSE([app isHandlingSendEvent]);
26 { 53 {
27 base::mac::ScopedSendingEvent is_handling_send_event; 54 base::mac::ScopedSendingEvent is_handling_send_event;
28 EXPECT_TRUE([app isHandlingSendEvent]); 55 EXPECT_TRUE([app isHandlingSendEvent]);
29 { 56 {
30 base::mac::ScopedSendingEvent nested_is_handling_send_event; 57 base::mac::ScopedSendingEvent nested_is_handling_send_event;
31 EXPECT_TRUE([app isHandlingSendEvent]); 58 EXPECT_TRUE([app isHandlingSendEvent]);
32 } 59 }
33 EXPECT_TRUE([app isHandlingSendEvent]); 60 EXPECT_TRUE([app isHandlingSendEvent]);
34 } 61 }
35 EXPECT_FALSE([app isHandlingSendEvent]); 62 EXPECT_FALSE([app isHandlingSendEvent]);
36 } 63 }
37 64
38 } // namespace 65 } // namespace
OLDNEW
« no previous file with comments | « no previous file | base/test/test_suite.cc » ('j') | ui/app_list/test/run_all_unittests.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698