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

Side by Side Diff: ios/chrome/browser/ui/keyboard/hardware_keyboard_watcher_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: Fix HardwardKeyboard test 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
« no previous file with comments | « ios/chrome/browser/ui/context_menu/context_menu_provider.h ('k') | ios/chrome/ios_chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/keyboard/hardware_keyboard_watcher.h" 5 #import "ios/chrome/browser/ui/keyboard/hardware_keyboard_watcher.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
11 #import "third_party/ocmock/OCMock/OCMock.h" 11 #import "third_party/ocmock/OCMock/OCMock.h"
12 12
13 namespace { 13 namespace {
14 14
15 void PostKeyboardWillChangeNotification(CGRect beginFrame, CGRect endFrame) { 15 void PostKeyboardWillChangeNotification(CGRect beginFrame, CGRect endFrame) {
16 [[NSNotificationCenter defaultCenter] 16 [[NSNotificationCenter defaultCenter]
17 postNotificationName:UIKeyboardWillChangeFrameNotification 17 postNotificationName:UIKeyboardWillChangeFrameNotification
18 object:nil 18 object:nil
19 userInfo:@{ 19 userInfo:@{
20 UIKeyboardFrameBeginUserInfoKey : 20 UIKeyboardFrameBeginUserInfoKey :
21 [NSValue valueWithCGRect:beginFrame], 21 [NSValue valueWithCGRect:beginFrame],
22 UIKeyboardFrameEndUserInfoKey : 22 UIKeyboardFrameEndUserInfoKey :
23 [NSValue valueWithCGRect:endFrame], 23 [NSValue valueWithCGRect:endFrame],
24 }]; 24 }];
25 } 25 }
26 26
27 typedef PlatformTest HardwareKeyboardWatcherTest; 27 class HardwareKeyboardWatcherTest : public PlatformTest {
28 public:
29 HardwareKeyboardWatcherTest() {
30 _window.reset(
31 [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]);
32 [_window makeKeyAndVisible];
33 }
34
35 protected:
36 base::scoped_nsobject<UIWindow> _window;
37 };
28 38
29 TEST_F(HardwareKeyboardWatcherTest, AccessoryViewNotInHierarchy_NoHistogram) { 39 TEST_F(HardwareKeyboardWatcherTest, AccessoryViewNotInHierarchy_NoHistogram) {
30 base::HistogramTester histogram_tester; 40 base::HistogramTester histogram_tester;
31 id mockView = [OCMockObject niceMockForClass:[UIView class]]; 41 id mockView = [OCMockObject niceMockForClass:[UIView class]];
32 [[mockView stub] andReturn:nil]; 42 [[mockView stub] andReturn:nil];
33 base::scoped_nsobject<HardwareKeyboardWatcher> watcher( 43 base::scoped_nsobject<HardwareKeyboardWatcher> watcher(
34 [[HardwareKeyboardWatcher alloc] initWithAccessoryView:mockView]); 44 [[HardwareKeyboardWatcher alloc] initWithAccessoryView:mockView]);
35 45
36 PostKeyboardWillChangeNotification(CGRectZero, CGRectZero); 46 PostKeyboardWillChangeNotification(CGRectZero, CGRectZero);
37 PostKeyboardWillChangeNotification(CGRectInfinite, CGRectInfinite); 47 PostKeyboardWillChangeNotification(CGRectInfinite, CGRectInfinite);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 [[HardwareKeyboardWatcher alloc] initWithAccessoryView:mockView]); 119 [[HardwareKeyboardWatcher alloc] initWithAccessoryView:mockView]);
110 120
111 PostKeyboardWillChangeNotification(CGRectMake(0, -50, 100, 100), 121 PostKeyboardWillChangeNotification(CGRectMake(0, -50, 100, 100),
112 CGRectMake(0, 0, 100, 100)); 122 CGRectMake(0, 0, 100, 100));
113 123
114 histogram_tester.ExpectUniqueSample("Omnibox.HardwareKeyboardModeEnabled", 124 histogram_tester.ExpectUniqueSample("Omnibox.HardwareKeyboardModeEnabled",
115 true, 1); 125 true, 1);
116 } 126 }
117 127
118 } // namespace 128 } // namespace
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/context_menu/context_menu_provider.h ('k') | ios/chrome/ios_chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698