Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / base / mac / scoped_sending_event_unittest.mm
blob9ae99856c9e76e37b169e4d886ccea42a51eddcb
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
3 // found in the LICENSE file.
5 #import "base/mac/scoped_sending_event.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace {
11 // Sets the flag within scope, resets when leaving scope.
12 TEST(ScopedSendingEventTest, SetHandlingSendEvent) {
13   id<CrAppProtocol> app = NSApp;
14   EXPECT_FALSE([app isHandlingSendEvent]);
15   {
16     base::mac::ScopedSendingEvent is_handling_send_event;
17     EXPECT_TRUE([app isHandlingSendEvent]);
18   }
19   EXPECT_FALSE([app isHandlingSendEvent]);
22 // Nested call restores previous value rather than resetting flag.
23 TEST(ScopedSendingEventTest, NestedSetHandlingSendEvent) {
24   id<CrAppProtocol> app = NSApp;
25   EXPECT_FALSE([app isHandlingSendEvent]);
26   {
27     base::mac::ScopedSendingEvent is_handling_send_event;
28     EXPECT_TRUE([app isHandlingSendEvent]);
29     {
30       base::mac::ScopedSendingEvent nested_is_handling_send_event;
31       EXPECT_TRUE([app isHandlingSendEvent]);
32     }
33     EXPECT_TRUE([app isHandlingSendEvent]);
34   }
35   EXPECT_FALSE([app isHandlingSendEvent]);
38 }  // namespace