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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 301 } |
302 | 302 |
303 void ActivateViewWithTextInputManager(RenderWidgetHostViewBase* view, | 303 void ActivateViewWithTextInputManager(RenderWidgetHostViewBase* view, |
304 ui::TextInputType type) { | 304 ui::TextInputType type) { |
305 TextInputState state; | 305 TextInputState state; |
306 state.type = type; | 306 state.type = type; |
307 view->TextInputStateChanged(state); | 307 view->TextInputStateChanged(state); |
308 } | 308 } |
309 | 309 |
310 protected: | 310 protected: |
311 std::string selected_text() const { return rwhv_mac_->selected_text_; } | 311 base::string16 selected_text() const { return rwhv_mac_->selected_text_; } |
312 | 312 |
313 RenderWidgetHostViewMac* rwhv_mac_; | 313 RenderWidgetHostViewMac* rwhv_mac_; |
314 base::scoped_nsobject<RenderWidgetHostViewCocoa> rwhv_cocoa_; | 314 base::scoped_nsobject<RenderWidgetHostViewCocoa> rwhv_cocoa_; |
315 | 315 |
316 private: | 316 private: |
317 // This class isn't derived from PlatformTest. | 317 // This class isn't derived from PlatformTest. |
318 base::mac::ScopedNSAutoreleasePool pool_; | 318 base::mac::ScopedNSAutoreleasePool pool_; |
319 | 319 |
320 RenderWidgetHostView* old_rwhv_; | 320 RenderWidgetHostView* old_rwhv_; |
321 | 321 |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 [view->cocoa_view() scrollWheel:wheelEvent]; | 1333 [view->cocoa_view() scrollWheel:wheelEvent]; |
1334 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); | 1334 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); |
1335 | 1335 |
1336 // Clean up. | 1336 // Clean up. |
1337 host->ShutdownAndDestroyWidget(true); | 1337 host->ShutdownAndDestroyWidget(true); |
1338 } | 1338 } |
1339 | 1339 |
1340 // This test verifies that |selected_text_| is updated accordingly with | 1340 // This test verifies that |selected_text_| is updated accordingly with |
1341 // different variations of RWHVMac::SelectChanged updates. | 1341 // different variations of RWHVMac::SelectChanged updates. |
1342 TEST_F(RenderWidgetHostViewMacTest, SelectedText) { | 1342 TEST_F(RenderWidgetHostViewMacTest, SelectedText) { |
1343 base::string16 sample_text; | 1343 base::string16 sample_text = base::ASCIIToUTF16("hello world!"); |
1344 base::UTF8ToUTF16("hello world!", 12, &sample_text); | |
1345 gfx::Range range(6, 11); | 1344 gfx::Range range(6, 11); |
1346 | 1345 |
1347 // Send a valid selection for the word 'World'. | 1346 // Send a valid selection for the word 'World'. |
1348 rwhv_mac_->SelectionChanged(sample_text, 0U, range); | 1347 rwhv_mac_->SelectionChanged(sample_text, 0U, range); |
1349 EXPECT_EQ("world", selected_text()); | 1348 EXPECT_EQ(base::ASCIIToUTF16("world"), selected_text()); |
1350 | 1349 |
1351 // Make the range cover some of the text and extend more. | 1350 // Make the range cover some of the text and extend more. |
1352 range.set_end(100); | 1351 range.set_end(100); |
1353 rwhv_mac_->SelectionChanged(sample_text, 0U, range); | 1352 rwhv_mac_->SelectionChanged(sample_text, 0U, range); |
1354 EXPECT_EQ("world!", selected_text()); | 1353 EXPECT_EQ(base::ASCIIToUTF16("world!"), selected_text()); |
1355 | 1354 |
1356 // Finally, send an empty range. This should clear the selected text. | 1355 // Finally, send an empty range. This should clear the selected text. |
1357 range.set_start(100); | 1356 range.set_start(100); |
1358 rwhv_mac_->SelectionChanged(sample_text, 0U, range); | 1357 rwhv_mac_->SelectionChanged(sample_text, 0U, range); |
1359 EXPECT_EQ("", selected_text()); | 1358 EXPECT_EQ(base::string16(), selected_text()); |
1360 } | 1359 } |
1361 | 1360 |
1362 // This class is used for IME-related unit tests which verify correctness of IME | 1361 // This class is used for IME-related unit tests which verify correctness of IME |
1363 // for pages with multiple RWHVs. | 1362 // for pages with multiple RWHVs. |
1364 class InputMethodMacTest : public RenderWidgetHostViewMacTest { | 1363 class InputMethodMacTest : public RenderWidgetHostViewMacTest { |
1365 public: | 1364 public: |
1366 InputMethodMacTest() {} | 1365 InputMethodMacTest() {} |
1367 ~InputMethodMacTest() override {} | 1366 ~InputMethodMacTest() override {} |
1368 | 1367 |
1369 void SetUp() override { | 1368 void SetUp() override { |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 // Verify that this IPC is asking for no monitoring or immediate updates. | 1639 // Verify that this IPC is asking for no monitoring or immediate updates. |
1641 InputMsg_RequestCompositionUpdate::Read(composition_request_msg_for_child, | 1640 InputMsg_RequestCompositionUpdate::Read(composition_request_msg_for_child, |
1642 &child_msg_params); | 1641 &child_msg_params); |
1643 is_child_msg_for_immediate_request = std::get<0>(child_msg_params); | 1642 is_child_msg_for_immediate_request = std::get<0>(child_msg_params); |
1644 is_child_msg_for_monitor_request = std::get<1>(child_msg_params); | 1643 is_child_msg_for_monitor_request = std::get<1>(child_msg_params); |
1645 EXPECT_FALSE(is_child_msg_for_immediate_request); | 1644 EXPECT_FALSE(is_child_msg_for_immediate_request); |
1646 EXPECT_FALSE(is_child_msg_for_monitor_request); | 1645 EXPECT_FALSE(is_child_msg_for_monitor_request); |
1647 } | 1646 } |
1648 | 1647 |
1649 } // namespace content | 1648 } // namespace content |
OLD | NEW |