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

Side by Side Diff: ios/chrome/browser/ui/key_commands_provider_unittest.mm

Issue 2970553002: [ios] Remove IDC_CLOSE_TAB
Patch Set: Add comment for chrome_test_util.h" Created 3 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/browser/ui/key_commands_provider.h" 5 #import "ios/chrome/browser/ui/key_commands_provider.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/platform_test.h" 8 #include "testing/platform_test.h"
9 #include "third_party/ocmock/OCMock/OCMock.h" 9 #include "third_party/ocmock/OCMock/OCMock.h"
10 #include "third_party/ocmock/gtest_support.h" 10 #include "third_party/ocmock/gtest_support.h"
11 #import "third_party/ocmock/ocmock_extensions.h" 11 #import "third_party/ocmock/ocmock_extensions.h"
12 12
13 #if !defined(__has_feature) || !__has_feature(objc_arc) 13 #if !defined(__has_feature) || !__has_feature(objc_arc)
14 #error "This file requires ARC support." 14 #error "This file requires ARC support."
15 #endif 15 #endif
16 16
17 namespace { 17 namespace {
18 18
19 typedef PlatformTest KeyCommandsProviderTest; 19 typedef PlatformTest KeyCommandsProviderTest;
20 20
21 TEST(KeyCommandsProviderTest, NoTabs_EditingText_ReturnsObjects) { 21 TEST(KeyCommandsProviderTest, NoTabs_EditingText_ReturnsObjects) {
22 KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init]; 22 KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init];
23 id mockConsumer = 23 id mockConsumer =
24 [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)]; 24 [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)];
25 id<BrowserCommands> dispatcher = nil;
25 [[[mockConsumer expect] andReturnUnsignedInteger:0] tabsCount]; 26 [[[mockConsumer expect] andReturnUnsignedInteger:0] tabsCount];
26 27
27 EXPECT_NE(nil, 28 EXPECT_NE(nil, [provider keyCommandsForConsumer:mockConsumer
28 [provider keyCommandsForConsumer:mockConsumer editingText:YES]); 29 browserCommandDispatcher:dispatcher
30 editingText:YES]);
29 } 31 }
30 32
31 TEST(KeyCommandsProviderTest, ReturnsKeyCommandsObjects) { 33 TEST(KeyCommandsProviderTest, ReturnsKeyCommandsObjects) {
32 KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init]; 34 KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init];
33 id mockConsumer = 35 id mockConsumer =
34 [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)]; 36 [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)];
37 id<BrowserCommands> dispatcher = nil;
38
35 [[[mockConsumer expect] andReturnUnsignedInteger:0] tabsCount]; 39 [[[mockConsumer expect] andReturnUnsignedInteger:0] tabsCount];
36 40
37 for (id element in 41 for (id element in [provider keyCommandsForConsumer:mockConsumer
38 [provider keyCommandsForConsumer:mockConsumer editingText:YES]) { 42 browserCommandDispatcher:dispatcher
43 editingText:YES]) {
39 EXPECT_TRUE([element isKindOfClass:[UIKeyCommand class]]); 44 EXPECT_TRUE([element isKindOfClass:[UIKeyCommand class]]);
40 } 45 }
41 } 46 }
42 47
43 TEST(KeyCommandsProviderTest, MoreKeyboardCommandsWhenTabs) { 48 TEST(KeyCommandsProviderTest, MoreKeyboardCommandsWhenTabs) {
44 KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init]; 49 KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init];
45 id mockConsumer = 50 id mockConsumer =
46 [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)]; 51 [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)];
52 id<BrowserCommands> dispatcher = nil;
47 53
48 // No tabs. 54 // No tabs.
49 [[[mockConsumer expect] andReturnUnsignedInteger:0] tabsCount]; 55 [[[mockConsumer expect] andReturnUnsignedInteger:0] tabsCount];
50 NSUInteger numberOfKeyCommandsWithoutTabs = 56 NSUInteger numberOfKeyCommandsWithoutTabs =
51 [[provider keyCommandsForConsumer:mockConsumer editingText:NO] count]; 57 [[provider keyCommandsForConsumer:mockConsumer
58 browserCommandDispatcher:dispatcher
59 editingText:NO] count];
52 60
53 // Tabs. 61 // Tabs.
54 [[[mockConsumer expect] andReturnUnsignedInteger:1] tabsCount]; 62 [[[mockConsumer expect] andReturnUnsignedInteger:1] tabsCount];
55 NSUInteger numberOfKeyCommandsWithTabs = 63 NSUInteger numberOfKeyCommandsWithTabs =
56 [[provider keyCommandsForConsumer:mockConsumer editingText:NO] count]; 64 [[provider keyCommandsForConsumer:mockConsumer
65 browserCommandDispatcher:dispatcher
66 editingText:NO] count];
57 67
58 EXPECT_GT(numberOfKeyCommandsWithTabs, numberOfKeyCommandsWithoutTabs); 68 EXPECT_GT(numberOfKeyCommandsWithTabs, numberOfKeyCommandsWithoutTabs);
59 } 69 }
60 70
61 TEST(KeyCommandsProviderTest, LessKeyCommandsWhenTabsAndEditingText) { 71 TEST(KeyCommandsProviderTest, LessKeyCommandsWhenTabsAndEditingText) {
62 KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init]; 72 KeyCommandsProvider* provider = [[KeyCommandsProvider alloc] init];
63 id mockConsumer = 73 id mockConsumer =
64 [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)]; 74 [OCMockObject mockForProtocol:@protocol(KeyCommandsPlumbing)];
75 id<BrowserCommands> dispatcher = nil;
65 76
66 // Not editing text. 77 // Not editing text.
67 [[[mockConsumer expect] andReturnUnsignedInteger:1] tabsCount]; 78 [[[mockConsumer expect] andReturnUnsignedInteger:1] tabsCount];
68 NSUInteger numberOfKeyCommandsWhenNotEditingText = 79 NSUInteger numberOfKeyCommandsWhenNotEditingText =
69 [[provider keyCommandsForConsumer:mockConsumer editingText:NO] count]; 80 [[provider keyCommandsForConsumer:mockConsumer
81 browserCommandDispatcher:dispatcher
82 editingText:NO] count];
70 83
71 // Editing text. 84 // Editing text.
72 [[[mockConsumer expect] andReturnUnsignedInteger:1] tabsCount]; 85 [[[mockConsumer expect] andReturnUnsignedInteger:1] tabsCount];
73 NSUInteger numberOfKeyCommandsWhenEditingText = 86 NSUInteger numberOfKeyCommandsWhenEditingText =
74 [[provider keyCommandsForConsumer:mockConsumer editingText:YES] count]; 87 [[provider keyCommandsForConsumer:mockConsumer
88 browserCommandDispatcher:dispatcher
89 editingText:YES] count];
75 90
76 EXPECT_LT(numberOfKeyCommandsWhenEditingText, 91 EXPECT_LT(numberOfKeyCommandsWhenEditingText,
77 numberOfKeyCommandsWhenNotEditingText); 92 numberOfKeyCommandsWhenNotEditingText);
78 } 93 }
79 94
80 } // namespace 95 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/key_commands_provider.mm ('k') | ios/chrome/browser/ui/ntp/google_landing_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698