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

Side by Side Diff: ios/chrome/browser/ui/context_menu/cru_context_menu_controller_unittest.mm

Issue 1891863004: Copy contents of ui/base/ios into ios/chrome/browser/ui/context_menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add to gn Created 4 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #import "ui/base/ios/cru_context_menu_controller.h" 5 #import "ui/base/ios/cru_context_menu_controller.h"
6 6
7 #import <UIKit/UIKit.h> 7 #import <UIKit/UIKit.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #import "ios/chrome/browser/ui/context_menu/cru_context_menu_controller.h"
11 #import "ios/chrome/browser/ui/context_menu/cru_context_menu_holder.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 13 #include "testing/platform_test.h"
12 #import "ui/base/ios/cru_context_menu_holder.h"
13 14
14 namespace { 15 namespace {
15 16
16 class ContextMenuControllerTest : public PlatformTest { 17 class ContextMenuControllerTest : public PlatformTest {
17 public: 18 public:
18 ContextMenuControllerTest() { } 19 ContextMenuControllerTest() {}
19 20
20 void SetUp() override { 21 void SetUp() override {
21 _menuController.reset([[CRUContextMenuController alloc] init]); 22 _menuController.reset([[ContextMenuController alloc] init]);
22 _window.reset( 23 _window.reset(
23 [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]); 24 [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]);
24 [_window makeKeyAndVisible]; 25 [_window makeKeyAndVisible];
25 } 26 }
26 27
27 protected: 28 protected:
28 base::scoped_nsobject<CRUContextMenuController> _menuController; 29 base::scoped_nsobject<ContextMenuController> _menuController;
29 base::scoped_nsobject<UIWindow> _window; 30 base::scoped_nsobject<UIWindow> _window;
30 }; 31 };
31 32
32 TEST_F(ContextMenuControllerTest, OneEntry) { 33 TEST_F(ContextMenuControllerTest, OneEntry) {
33 base::scoped_nsobject<CRUContextMenuHolder> holder( 34 base::scoped_nsobject<ContextMenuHolder> holder(
34 [[CRUContextMenuHolder alloc] init]); 35 [[ContextMenuHolder alloc] init]);
35 BOOL clicked = NO; 36 BOOL clicked = NO;
36 BOOL* clickedPtr = &clicked; 37 BOOL* clickedPtr = &clicked;
37 38
38 [holder appendItemWithTitle:@"foo" action:^{ *clickedPtr = YES; }]; 39 [holder appendItemWithTitle:@"foo"
Eugene But (OOO till 7-30) 2016/04/15 19:57:17 Optional NIT: This looks like a bug in clang forma
Jackie Quinn 2016/04/15 20:38:07 Done.
40 action:^{
41 *clickedPtr = YES;
42 }];
39 [holder setMenuTitle:@"FooTitle"]; 43 [holder setMenuTitle:@"FooTitle"];
40 44
41 [_menuController showWithHolder:holder atPoint:CGPointZero inView:_window]; 45 [_menuController showWithHolder:holder atPoint:CGPointZero inView:_window];
42 46
43 EXPECT_TRUE([_menuController isVisible]); 47 EXPECT_TRUE([_menuController isVisible]);
44 } 48 }
45 49
46 TEST_F(ContextMenuControllerTest, ShouldDismissImmediately) { 50 TEST_F(ContextMenuControllerTest, ShouldDismissImmediately) {
47 base::scoped_nsobject<CRUContextMenuHolder> holder( 51 base::scoped_nsobject<ContextMenuHolder> holder(
48 [[CRUContextMenuHolder alloc] init]); 52 [[ContextMenuHolder alloc] init]);
49 [holder appendItemWithTitle:@"foo" action:^{}]; 53 [holder appendItemWithTitle:@"foo"
Eugene But (OOO till 7-30) 2016/04/15 19:57:18 Optional NIT: Ditto. Old format is perfectly fine
Jackie Quinn 2016/04/15 20:38:07 Done.
50 [holder appendItemWithTitle:@"bar" action:^{} dismissImmediately:YES]; 54 action:^{
51 [holder appendItemWithTitle:@"baz" action:^{} dismissImmediately:NO]; 55 }];
56 [holder appendItemWithTitle:@"bar"
57 action:^{
58 }
59 dismissImmediately:YES];
60 [holder appendItemWithTitle:@"baz"
61 action:^{
62 }
63 dismissImmediately:NO];
52 64
53 EXPECT_FALSE([holder shouldDismissImmediatelyOnClickedAtIndex:0]); 65 EXPECT_FALSE([holder shouldDismissImmediatelyOnClickedAtIndex:0]);
54 EXPECT_TRUE([holder shouldDismissImmediatelyOnClickedAtIndex:1]); 66 EXPECT_TRUE([holder shouldDismissImmediatelyOnClickedAtIndex:1]);
55 EXPECT_FALSE([holder shouldDismissImmediatelyOnClickedAtIndex:2]); 67 EXPECT_FALSE([holder shouldDismissImmediatelyOnClickedAtIndex:2]);
56 } 68 }
57 69
58 } // namespace 70 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698