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

Side by Side Diff: ui/base/ios/cru_context_menu_controller_unittest.mm

Issue 1103743002: Use UIAlertController on iOS8 for Context Menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolved Sylvain's review comments Created 5 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 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 23 matching lines...) Expand all
34 [[CRUContextMenuHolder alloc] init]); 34 [[CRUContextMenuHolder alloc] init]);
35 BOOL clicked = NO; 35 BOOL clicked = NO;
36 BOOL* clickedPtr = &clicked; 36 BOOL* clickedPtr = &clicked;
37 37
38 [holder appendItemWithTitle:@"foo" action:^{ *clickedPtr = YES; }]; 38 [holder appendItemWithTitle:@"foo" action:^{ *clickedPtr = YES; }];
39 [holder setMenuTitle:@"FooTitle"]; 39 [holder setMenuTitle:@"FooTitle"];
40 40
41 [_menuController showWithHolder:holder atPoint:CGPointZero inView:_window]; 41 [_menuController showWithHolder:holder atPoint:CGPointZero inView:_window];
42 42
43 EXPECT_TRUE([_menuController isVisible]); 43 EXPECT_TRUE([_menuController isVisible]);
44
45 UIActionSheet* sheet = _menuController.get().sheet;
46 [sheet dismissWithClickedButtonIndex:0 animated:NO];
47 [_menuController actionSheet:sheet didDismissWithButtonIndex:0];
48
49 EXPECT_TRUE(clicked);
50 EXPECT_FALSE([_menuController isVisible]);
51 } 44 }
52 45
53 TEST_F(ContextMenuControllerTest, ShouldDismissImmediately) { 46 TEST_F(ContextMenuControllerTest, ShouldDismissImmediately) {
54 base::scoped_nsobject<CRUContextMenuHolder> holder( 47 base::scoped_nsobject<CRUContextMenuHolder> holder(
55 [[CRUContextMenuHolder alloc] init]); 48 [[CRUContextMenuHolder alloc] init]);
56 [holder appendItemWithTitle:@"foo" action:^{}]; 49 [holder appendItemWithTitle:@"foo" action:^{}];
57 [holder appendItemWithTitle:@"bar" action:^{} dismissImmediately:YES]; 50 [holder appendItemWithTitle:@"bar" action:^{} dismissImmediately:YES];
58 [holder appendItemWithTitle:@"baz" action:^{} dismissImmediately:NO]; 51 [holder appendItemWithTitle:@"baz" action:^{} dismissImmediately:NO];
59 52
60 EXPECT_FALSE([holder shouldDismissImmediatelyOnClickedAtIndex:0]); 53 EXPECT_FALSE([holder shouldDismissImmediatelyOnClickedAtIndex:0]);
61 EXPECT_TRUE([holder shouldDismissImmediatelyOnClickedAtIndex:1]); 54 EXPECT_TRUE([holder shouldDismissImmediatelyOnClickedAtIndex:1]);
62 EXPECT_FALSE([holder shouldDismissImmediatelyOnClickedAtIndex:2]); 55 EXPECT_FALSE([holder shouldDismissImmediatelyOnClickedAtIndex:2]);
63 } 56 }
64 57
65 } // namespace 58 } // namespace
OLDNEW
« ui/base/ios/cru_context_menu_controller.mm ('K') | « ui/base/ios/cru_context_menu_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698