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 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 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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; |
| 1344 base::UTF8ToUTF16("hello world!", 12, &sample_text); | 1344 base::UTF8ToUTF16("hello world!", 12, &sample_text); |
| 1345 gfx::Range range(6, 11); | 1345 gfx::Range range(6, 11); |
| 1346 | 1346 |
| 1347 // Send a valid selection for the word 'World'. | 1347 // Send a valid selection for the word 'World'. |
| 1348 rwhv_mac_->SelectionChanged(sample_text, 0U, range); | 1348 rwhv_mac_->SelectionChanged(sample_text, 0U, range); |
| 1349 EXPECT_EQ("world", selected_text()); | 1349 EXPECT_EQ(base::UTF8ToUTF16("world"), selected_text()); |
|
tapted
2017/02/03 10:14:51
nit: ASCIIToUTF16, same below
spqchan
2017/02/03 23:32:10
Done.
| |
| 1350 | 1350 |
| 1351 // Make the range cover some of the text and extend more. | 1351 // Make the range cover some of the text and extend more. |
| 1352 range.set_end(100); | 1352 range.set_end(100); |
| 1353 rwhv_mac_->SelectionChanged(sample_text, 0U, range); | 1353 rwhv_mac_->SelectionChanged(sample_text, 0U, range); |
| 1354 EXPECT_EQ("world!", selected_text()); | 1354 EXPECT_EQ(base::UTF8ToUTF16("world!"), selected_text()); |
| 1355 | 1355 |
| 1356 // Finally, send an empty range. This should clear the selected text. | 1356 // Finally, send an empty range. This should clear the selected text. |
| 1357 range.set_start(100); | 1357 range.set_start(100); |
| 1358 rwhv_mac_->SelectionChanged(sample_text, 0U, range); | 1358 rwhv_mac_->SelectionChanged(sample_text, 0U, range); |
| 1359 EXPECT_EQ("", selected_text()); | 1359 EXPECT_EQ(base::string16(), selected_text()); |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 // This class is used for IME-related unit tests which verify correctness of IME | 1362 // This class is used for IME-related unit tests which verify correctness of IME |
| 1363 // for pages with multiple RWHVs. | 1363 // for pages with multiple RWHVs. |
| 1364 class InputMethodMacTest : public RenderWidgetHostViewMacTest { | 1364 class InputMethodMacTest : public RenderWidgetHostViewMacTest { |
| 1365 public: | 1365 public: |
| 1366 InputMethodMacTest() {} | 1366 InputMethodMacTest() {} |
| 1367 ~InputMethodMacTest() override {} | 1367 ~InputMethodMacTest() override {} |
| 1368 | 1368 |
| 1369 void SetUp() override { | 1369 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. | 1640 // Verify that this IPC is asking for no monitoring or immediate updates. |
| 1641 InputMsg_RequestCompositionUpdate::Read(composition_request_msg_for_child, | 1641 InputMsg_RequestCompositionUpdate::Read(composition_request_msg_for_child, |
| 1642 &child_msg_params); | 1642 &child_msg_params); |
| 1643 is_child_msg_for_immediate_request = std::get<0>(child_msg_params); | 1643 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); | 1644 is_child_msg_for_monitor_request = std::get<1>(child_msg_params); |
| 1645 EXPECT_FALSE(is_child_msg_for_immediate_request); | 1645 EXPECT_FALSE(is_child_msg_for_immediate_request); |
| 1646 EXPECT_FALSE(is_child_msg_for_monitor_request); | 1646 EXPECT_FALSE(is_child_msg_for_monitor_request); |
| 1647 } | 1647 } |
| 1648 | 1648 |
| 1649 } // namespace content | 1649 } // namespace content |
| OLD | NEW |