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 <tuple> | 5 #include <tuple> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/spellcheck/common/spellcheck_marker.h" | 9 #include "components/spellcheck/common/spellcheck_marker.h" |
10 #include "components/spellcheck/common/spellcheck_messages.h" | 10 #include "components/spellcheck/common/spellcheck_messages.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 provider_.RequestTextChecking(blink::WebString("hello "), | 36 provider_.RequestTextChecking(blink::WebString("hello "), |
37 &completion, | 37 &completion, |
38 std::vector<SpellCheckMarker>()); | 38 std::vector<SpellCheckMarker>()); |
39 EXPECT_EQ(completion.completion_count_, 0U); | 39 EXPECT_EQ(completion.completion_count_, 0U); |
40 EXPECT_EQ(provider_.messages_.size(), 1U); | 40 EXPECT_EQ(provider_.messages_.size(), 1U); |
41 EXPECT_EQ(provider_.pending_text_request_size(), 1U); | 41 EXPECT_EQ(provider_.pending_text_request_size(), 1U); |
42 | 42 |
43 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1; | 43 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1; |
44 bool ok = SpellCheckHostMsg_RequestTextCheck::Read( | 44 bool ok = SpellCheckHostMsg_RequestTextCheck::Read( |
45 provider_.messages_[0], &read_parameters1); | 45 provider_.messages_[0].get(), &read_parameters1); |
46 EXPECT_TRUE(ok); | 46 EXPECT_TRUE(ok); |
47 EXPECT_EQ(std::get<2>(read_parameters1), base::UTF8ToUTF16("hello ")); | 47 EXPECT_EQ(std::get<2>(read_parameters1), base::UTF8ToUTF16("hello ")); |
48 | 48 |
49 FakeMessageArrival(&provider_, read_parameters1); | 49 FakeMessageArrival(&provider_, read_parameters1); |
50 EXPECT_EQ(completion.completion_count_, 1U); | 50 EXPECT_EQ(completion.completion_count_, 1U); |
51 EXPECT_EQ(provider_.pending_text_request_size(), 0U); | 51 EXPECT_EQ(provider_.pending_text_request_size(), 0U); |
52 } | 52 } |
53 | 53 |
54 TEST_F(SpellCheckProviderMacTest, TwoRoundtripSuccess) { | 54 TEST_F(SpellCheckProviderMacTest, TwoRoundtripSuccess) { |
55 FakeTextCheckingCompletion completion1; | 55 FakeTextCheckingCompletion completion1; |
56 provider_.RequestTextChecking(blink::WebString("hello "), | 56 provider_.RequestTextChecking(blink::WebString("hello "), |
57 &completion1, | 57 &completion1, |
58 std::vector<SpellCheckMarker>()); | 58 std::vector<SpellCheckMarker>()); |
59 FakeTextCheckingCompletion completion2; | 59 FakeTextCheckingCompletion completion2; |
60 provider_.RequestTextChecking(blink::WebString("bye "), | 60 provider_.RequestTextChecking(blink::WebString("bye "), |
61 &completion2, | 61 &completion2, |
62 std::vector<SpellCheckMarker>()); | 62 std::vector<SpellCheckMarker>()); |
63 | 63 |
64 EXPECT_EQ(completion1.completion_count_, 0U); | 64 EXPECT_EQ(completion1.completion_count_, 0U); |
65 EXPECT_EQ(completion2.completion_count_, 0U); | 65 EXPECT_EQ(completion2.completion_count_, 0U); |
66 EXPECT_EQ(provider_.messages_.size(), 2U); | 66 EXPECT_EQ(provider_.messages_.size(), 2U); |
67 EXPECT_EQ(provider_.pending_text_request_size(), 2U); | 67 EXPECT_EQ(provider_.pending_text_request_size(), 2U); |
68 | 68 |
69 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1; | 69 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1; |
70 bool ok = SpellCheckHostMsg_RequestTextCheck::Read( | 70 bool ok = SpellCheckHostMsg_RequestTextCheck::Read( |
71 provider_.messages_[0], &read_parameters1); | 71 provider_.messages_[0].get(), &read_parameters1); |
72 EXPECT_TRUE(ok); | 72 EXPECT_TRUE(ok); |
73 EXPECT_EQ(std::get<2>(read_parameters1), base::UTF8ToUTF16("hello ")); | 73 EXPECT_EQ(std::get<2>(read_parameters1), base::UTF8ToUTF16("hello ")); |
74 | 74 |
75 SpellCheckHostMsg_RequestTextCheck::Param read_parameters2; | 75 SpellCheckHostMsg_RequestTextCheck::Param read_parameters2; |
76 ok = SpellCheckHostMsg_RequestTextCheck::Read( | 76 ok = SpellCheckHostMsg_RequestTextCheck::Read(provider_.messages_[1].get(), |
77 provider_.messages_[1], &read_parameters2); | 77 &read_parameters2); |
78 EXPECT_TRUE(ok); | 78 EXPECT_TRUE(ok); |
79 EXPECT_EQ(std::get<2>(read_parameters2), base::UTF8ToUTF16("bye ")); | 79 EXPECT_EQ(std::get<2>(read_parameters2), base::UTF8ToUTF16("bye ")); |
80 | 80 |
81 FakeMessageArrival(&provider_, read_parameters1); | 81 FakeMessageArrival(&provider_, read_parameters1); |
82 EXPECT_EQ(completion1.completion_count_, 1U); | 82 EXPECT_EQ(completion1.completion_count_, 1U); |
83 EXPECT_EQ(completion2.completion_count_, 0U); | 83 EXPECT_EQ(completion2.completion_count_, 0U); |
84 EXPECT_EQ(provider_.pending_text_request_size(), 1U); | 84 EXPECT_EQ(provider_.pending_text_request_size(), 1U); |
85 | 85 |
86 FakeMessageArrival(&provider_, read_parameters2); | 86 FakeMessageArrival(&provider_, read_parameters2); |
87 EXPECT_EQ(completion1.completion_count_, 1U); | 87 EXPECT_EQ(completion1.completion_count_, 1U); |
88 EXPECT_EQ(completion2.completion_count_, 1U); | 88 EXPECT_EQ(completion2.completion_count_, 1U); |
89 EXPECT_EQ(provider_.pending_text_request_size(), 0U); | 89 EXPECT_EQ(provider_.pending_text_request_size(), 0U); |
90 } | 90 } |
91 | 91 |
92 } // namespace | 92 } // namespace |
OLD | NEW |