Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #include <Cocoa/Cocoa.h> | 7 #include <Cocoa/Cocoa.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 view->TextInputStateChanged(state); | 298 view->TextInputStateChanged(state); |
| 299 } | 299 } |
| 300 | 300 |
| 301 private: | 301 private: |
| 302 // This class isn't derived from PlatformTest. | 302 // This class isn't derived from PlatformTest. |
| 303 base::mac::ScopedNSAutoreleasePool pool_; | 303 base::mac::ScopedNSAutoreleasePool pool_; |
| 304 | 304 |
| 305 RenderWidgetHostView* old_rwhv_; | 305 RenderWidgetHostView* old_rwhv_; |
| 306 | 306 |
| 307 protected: | 307 protected: |
| 308 std::string selected_text() const { return rwhv_mac_->selected_text_; } | |
| 309 | |
| 308 RenderWidgetHostViewMac* rwhv_mac_; | 310 RenderWidgetHostViewMac* rwhv_mac_; |
| 309 base::scoped_nsobject<RenderWidgetHostViewCocoa> rwhv_cocoa_; | 311 base::scoped_nsobject<RenderWidgetHostViewCocoa> rwhv_cocoa_; |
| 310 | 312 |
| 311 private: | 313 private: |
|
EhsanK
2016/12/22 20:06:23
Weird formatting here with private->protected->pri
Avi (use Gerrit)
2016/12/22 20:11:56
Don't TBR, but please do send a followup CL to me
| |
| 312 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMacTest); | 314 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMacTest); |
| 313 }; | 315 }; |
| 314 | 316 |
| 315 TEST_F(RenderWidgetHostViewMacTest, Basic) { | 317 TEST_F(RenderWidgetHostViewMacTest, Basic) { |
| 316 } | 318 } |
| 317 | 319 |
| 318 TEST_F(RenderWidgetHostViewMacTest, AcceptsFirstResponder) { | 320 TEST_F(RenderWidgetHostViewMacTest, AcceptsFirstResponder) { |
| 319 // The RWHVCocoa should normally accept first responder status. | 321 // The RWHVCocoa should normally accept first responder status. |
| 320 EXPECT_TRUE([rwhv_cocoa_.get() acceptsFirstResponder]); | 322 EXPECT_TRUE([rwhv_cocoa_.get() acceptsFirstResponder]); |
| 321 } | 323 } |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1321 // Send an initial wheel event for scrolling by 3 lines. | 1323 // Send an initial wheel event for scrolling by 3 lines. |
| 1322 // Verify that Event.Latency.OS.MOUSE_WHEEL histogram is computed properly. | 1324 // Verify that Event.Latency.OS.MOUSE_WHEEL histogram is computed properly. |
| 1323 NSEvent* wheelEvent = MockScrollWheelEventWithPhase(@selector(phaseBegan),3); | 1325 NSEvent* wheelEvent = MockScrollWheelEventWithPhase(@selector(phaseBegan),3); |
| 1324 [view->cocoa_view() scrollWheel:wheelEvent]; | 1326 [view->cocoa_view() scrollWheel:wheelEvent]; |
| 1325 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); | 1327 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); |
| 1326 | 1328 |
| 1327 // Clean up. | 1329 // Clean up. |
| 1328 host->ShutdownAndDestroyWidget(true); | 1330 host->ShutdownAndDestroyWidget(true); |
| 1329 } | 1331 } |
| 1330 | 1332 |
| 1333 // This test verifies that |selected_text_| is updated accordingly with | |
| 1334 // different variations of RWHVMac::SelectChanged updates. | |
| 1335 TEST_F(RenderWidgetHostViewMacTest, SelectedText) { | |
| 1336 base::string16 sample_text; | |
| 1337 base::UTF8ToUTF16("hello world!", 12, &sample_text); | |
| 1338 gfx::Range range(6, 11); | |
| 1339 | |
| 1340 // Send a valid selection for the word 'World'. | |
| 1341 rwhv_mac_->SelectionChanged(sample_text, 0U, range); | |
| 1342 EXPECT_EQ("world", selected_text()); | |
| 1343 | |
| 1344 // Make the range cover some of the text and extend more. | |
| 1345 range.set_end(100); | |
| 1346 rwhv_mac_->SelectionChanged(sample_text, 0U, range); | |
| 1347 EXPECT_EQ("world!", selected_text()); | |
| 1348 | |
| 1349 // Finally, send an empty range. This should clear the selected text. | |
| 1350 range.set_start(100); | |
| 1351 rwhv_mac_->SelectionChanged(sample_text, 0U, range); | |
| 1352 EXPECT_EQ("", selected_text()); | |
| 1353 } | |
| 1354 | |
| 1331 // This class is used for IME-related unit tests which verify correctness of IME | 1355 // This class is used for IME-related unit tests which verify correctness of IME |
| 1332 // for pages with multiple RWHVs. | 1356 // for pages with multiple RWHVs. |
| 1333 class InputMethodMacTest : public RenderWidgetHostViewMacTest { | 1357 class InputMethodMacTest : public RenderWidgetHostViewMacTest { |
| 1334 public: | 1358 public: |
| 1335 InputMethodMacTest() {} | 1359 InputMethodMacTest() {} |
| 1336 ~InputMethodMacTest() override {} | 1360 ~InputMethodMacTest() override {} |
| 1337 void SetUp() override { | 1361 void SetUp() override { |
| 1338 RenderWidgetHostViewMacTest::SetUp(); | 1362 RenderWidgetHostViewMacTest::SetUp(); |
| 1339 | 1363 |
| 1340 // Initializing a child frame's view. | 1364 // Initializing a child frame's view. |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1608 // Verify that this IPC is asking for no monitoring or immediate updates. | 1632 // Verify that this IPC is asking for no monitoring or immediate updates. |
| 1609 InputMsg_RequestCompositionUpdate::Read(composition_request_msg_for_child, | 1633 InputMsg_RequestCompositionUpdate::Read(composition_request_msg_for_child, |
| 1610 &child_msg_params); | 1634 &child_msg_params); |
| 1611 is_child_msg_for_immediate_request = std::get<0>(child_msg_params); | 1635 is_child_msg_for_immediate_request = std::get<0>(child_msg_params); |
| 1612 is_child_msg_for_monitor_request = std::get<1>(child_msg_params); | 1636 is_child_msg_for_monitor_request = std::get<1>(child_msg_params); |
| 1613 EXPECT_FALSE(is_child_msg_for_immediate_request); | 1637 EXPECT_FALSE(is_child_msg_for_immediate_request); |
| 1614 EXPECT_FALSE(is_child_msg_for_monitor_request); | 1638 EXPECT_FALSE(is_child_msg_for_monitor_request); |
| 1615 } | 1639 } |
| 1616 | 1640 |
| 1617 } // namespace content | 1641 } // namespace content |
| OLD | NEW |