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

Side by Side Diff: chrome/browser/cocoa/event_utils_unittest.mm

Issue 402066: Moved a whole pile of unittests over to CocoaTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <objc/objc-class.h> 5 #import <objc/objc-class.h>
6 6
7 #import "chrome/browser/cocoa/cocoa_test_helper.h" 7 #import "chrome/browser/cocoa/cocoa_test_helper.h"
8 #include "chrome/browser/cocoa/event_utils.h" 8 #include "chrome/browser/cocoa/event_utils.h"
9 #include "chrome/browser/cocoa/test_event_utils.h" 9 #include "chrome/browser/cocoa/test_event_utils.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
12 12
13 // We provide a donor class with a specially modified |modifierFlags| 13 // We provide a donor class with a specially modified |modifierFlags|
14 // implementation that we swap with NSEvent's. This is because we can't create a 14 // implementation that we swap with NSEvent's. This is because we can't create a
15 // NSEvent that represents a middle click with modifiers. 15 // NSEvent that represents a middle click with modifiers.
16 @interface TestEvent : NSObject 16 @interface TestEvent : NSObject
17 @end 17 @end
18 @implementation TestEvent 18 @implementation TestEvent
19 - (NSUInteger)modifierFlags { return NSShiftKeyMask; } 19 - (NSUInteger)modifierFlags { return NSShiftKeyMask; }
20 @end 20 @end
21 21
22 namespace { 22 namespace {
23 23
24 class EventUtilsTest : public PlatformTest { 24 class EventUtilsTest : public CocoaTest {
25 private:
26 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
27 }; 25 };
28 26
29 TEST_F(EventUtilsTest, TestWindowOpenDispositionFromNSEvent) { 27 TEST_F(EventUtilsTest, TestWindowOpenDispositionFromNSEvent) {
30 // Left Click = same tab. 28 // Left Click = same tab.
31 NSEvent* me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, 0); 29 NSEvent* me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, 0);
32 EXPECT_EQ(CURRENT_TAB, event_utils::WindowOpenDispositionFromNSEvent(me)); 30 EXPECT_EQ(CURRENT_TAB, event_utils::WindowOpenDispositionFromNSEvent(me));
33 31
34 // Middle Click = new background tab. 32 // Middle Click = new background tab.
35 me = test_event_utils::MakeMouseEvent(NSOtherMouseUp, 0); 33 me = test_event_utils::MakeMouseEvent(NSOtherMouseUp, 0);
36 EXPECT_EQ(NEW_BACKGROUND_TAB, 34 EXPECT_EQ(NEW_BACKGROUND_TAB,
(...skipping 17 matching lines...) Expand all
54 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSCommandKeyMask | NSShif tKeyMask); 52 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSCommandKeyMask | NSShif tKeyMask);
55 EXPECT_EQ(NEW_FOREGROUND_TAB, 53 EXPECT_EQ(NEW_FOREGROUND_TAB,
56 event_utils::WindowOpenDispositionFromNSEvent(me)); 54 event_utils::WindowOpenDispositionFromNSEvent(me));
57 55
58 // Shift+Left Click = new window 56 // Shift+Left Click = new window
59 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSShiftKeyMask); 57 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSShiftKeyMask);
60 EXPECT_EQ(NEW_WINDOW, event_utils::WindowOpenDispositionFromNSEvent(me)); 58 EXPECT_EQ(NEW_WINDOW, event_utils::WindowOpenDispositionFromNSEvent(me));
61 } 59 }
62 60
63 } // namespace 61 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/download_shelf_view_unittest.mm ('k') | chrome/browser/cocoa/find_bar_cocoa_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698