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

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

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 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/mac/mach_logging.h ('k') | base/memory/discardable_shared_memory.h » ('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) 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> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 @interface ScopedSendingEventTestCrApp : NSObject <CrAppControlProtocol> { 12 @interface ScopedSendingEventTestCrApp : NSObject <CrAppControlProtocol> {
13 @private 13 @private
14 BOOL handlingSendEvent_; 14 BOOL handlingSendEvent_;
15 } 15 }
16 @property(nonatomic, assign, getter=isHandlingSendEvent) BOOL handlingSendEvent; 16 @property(nonatomic, assign, getter=isHandlingSendEvent) BOOL handlingSendEvent;
17 @end 17 @end
18 18
19 @implementation ScopedSendingEventTestCrApp 19 @implementation ScopedSendingEventTestCrApp
20 @synthesize handlingSendEvent = handlingSendEvent_; 20 @synthesize handlingSendEvent = handlingSendEvent_;
21 @end 21 @end
22 22
23 namespace { 23 namespace {
24 24
25 class ScopedSendingEventTest : public testing::Test { 25 class ScopedSendingEventTest : public testing::Test {
26 public: 26 public:
27 ScopedSendingEventTest() : app_([[ScopedSendingEventTestCrApp alloc] init]) { 27 ScopedSendingEventTest() : app_([[ScopedSendingEventTestCrApp alloc] init]) {
28 NSApp = app_.get(); 28 NSApp = app_.get();
29 } 29 }
30 virtual ~ScopedSendingEventTest() { 30 ~ScopedSendingEventTest() override { NSApp = nil; }
31 NSApp = nil;
32 }
33 31
34 private: 32 private:
35 base::scoped_nsobject<ScopedSendingEventTestCrApp> app_; 33 base::scoped_nsobject<ScopedSendingEventTestCrApp> app_;
36 }; 34 };
37 35
38 // Sets the flag within scope, resets when leaving scope. 36 // Sets the flag within scope, resets when leaving scope.
39 TEST_F(ScopedSendingEventTest, SetHandlingSendEvent) { 37 TEST_F(ScopedSendingEventTest, SetHandlingSendEvent) {
40 id<CrAppProtocol> app = NSApp; 38 id<CrAppProtocol> app = NSApp;
41 EXPECT_FALSE([app isHandlingSendEvent]); 39 EXPECT_FALSE([app isHandlingSendEvent]);
42 { 40 {
(...skipping 13 matching lines...) Expand all
56 { 54 {
57 base::mac::ScopedSendingEvent nested_is_handling_send_event; 55 base::mac::ScopedSendingEvent nested_is_handling_send_event;
58 EXPECT_TRUE([app isHandlingSendEvent]); 56 EXPECT_TRUE([app isHandlingSendEvent]);
59 } 57 }
60 EXPECT_TRUE([app isHandlingSendEvent]); 58 EXPECT_TRUE([app isHandlingSendEvent]);
61 } 59 }
62 EXPECT_FALSE([app isHandlingSendEvent]); 60 EXPECT_FALSE([app isHandlingSendEvent]);
63 } 61 }
64 62
65 } // namespace 63 } // namespace
OLDNEW
« no previous file with comments | « base/mac/mach_logging.h ('k') | base/memory/discardable_shared_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698