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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/common/spellcheck_marker.h" | 8 #include "chrome/common/spellcheck_marker.h" |
9 #include "chrome/common/spellcheck_messages.h" | 9 #include "chrome/common/spellcheck_messages.h" |
10 #include "chrome/common/spellcheck_result.h" | 10 #include "chrome/common/spellcheck_result.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 SpellCheckMsg_RespondTextCheck( | 46 SpellCheckMsg_RespondTextCheck( |
47 0, | 47 0, |
48 parameters.request_id, | 48 parameters.request_id, |
49 fake_result)); | 49 fake_result)); |
50 EXPECT_TRUE(handled); | 50 EXPECT_TRUE(handled); |
51 } | 51 } |
52 | 52 |
53 TEST_F(SpellCheckProviderMacTest, SingleRoundtripSuccess) { | 53 TEST_F(SpellCheckProviderMacTest, SingleRoundtripSuccess) { |
54 FakeTextCheckingCompletion completion; | 54 FakeTextCheckingCompletion completion; |
55 | 55 |
56 provider_.RequestTextChecking(WebKit::WebString("hello "), | 56 provider_.RequestTextChecking(blink::WebString("hello "), |
57 &completion, | 57 &completion, |
58 std::vector<SpellCheckMarker>()); | 58 std::vector<SpellCheckMarker>()); |
59 EXPECT_EQ(completion.completion_count_, 0U); | 59 EXPECT_EQ(completion.completion_count_, 0U); |
60 EXPECT_EQ(provider_.messages_.size(), 1U); | 60 EXPECT_EQ(provider_.messages_.size(), 1U); |
61 EXPECT_EQ(provider_.pending_text_request_size(), 1U); | 61 EXPECT_EQ(provider_.pending_text_request_size(), 1U); |
62 | 62 |
63 MessageParameters read_parameters = | 63 MessageParameters read_parameters = |
64 ReadRequestTextCheck(provider_.messages_[0]); | 64 ReadRequestTextCheck(provider_.messages_[0]); |
65 EXPECT_EQ(read_parameters.text, UTF8ToUTF16("hello ")); | 65 EXPECT_EQ(read_parameters.text, UTF8ToUTF16("hello ")); |
66 | 66 |
67 FakeMessageArrival(&provider_, read_parameters); | 67 FakeMessageArrival(&provider_, read_parameters); |
68 EXPECT_EQ(completion.completion_count_, 1U); | 68 EXPECT_EQ(completion.completion_count_, 1U); |
69 EXPECT_EQ(provider_.pending_text_request_size(), 0U); | 69 EXPECT_EQ(provider_.pending_text_request_size(), 0U); |
70 } | 70 } |
71 | 71 |
72 TEST_F(SpellCheckProviderMacTest, TwoRoundtripSuccess) { | 72 TEST_F(SpellCheckProviderMacTest, TwoRoundtripSuccess) { |
73 FakeTextCheckingCompletion completion1; | 73 FakeTextCheckingCompletion completion1; |
74 provider_.RequestTextChecking(WebKit::WebString("hello "), | 74 provider_.RequestTextChecking(blink::WebString("hello "), |
75 &completion1, | 75 &completion1, |
76 std::vector<SpellCheckMarker>()); | 76 std::vector<SpellCheckMarker>()); |
77 FakeTextCheckingCompletion completion2; | 77 FakeTextCheckingCompletion completion2; |
78 provider_.RequestTextChecking(WebKit::WebString("bye "), | 78 provider_.RequestTextChecking(blink::WebString("bye "), |
79 &completion2, | 79 &completion2, |
80 std::vector<SpellCheckMarker>()); | 80 std::vector<SpellCheckMarker>()); |
81 | 81 |
82 EXPECT_EQ(completion1.completion_count_, 0U); | 82 EXPECT_EQ(completion1.completion_count_, 0U); |
83 EXPECT_EQ(completion2.completion_count_, 0U); | 83 EXPECT_EQ(completion2.completion_count_, 0U); |
84 EXPECT_EQ(provider_.messages_.size(), 2U); | 84 EXPECT_EQ(provider_.messages_.size(), 2U); |
85 EXPECT_EQ(provider_.pending_text_request_size(), 2U); | 85 EXPECT_EQ(provider_.pending_text_request_size(), 2U); |
86 | 86 |
87 MessageParameters read_parameters1 = | 87 MessageParameters read_parameters1 = |
88 ReadRequestTextCheck(provider_.messages_[0]); | 88 ReadRequestTextCheck(provider_.messages_[0]); |
89 EXPECT_EQ(read_parameters1.text, UTF8ToUTF16("hello ")); | 89 EXPECT_EQ(read_parameters1.text, UTF8ToUTF16("hello ")); |
90 | 90 |
91 MessageParameters read_parameters2 = | 91 MessageParameters read_parameters2 = |
92 ReadRequestTextCheck(provider_.messages_[1]); | 92 ReadRequestTextCheck(provider_.messages_[1]); |
93 EXPECT_EQ(read_parameters2.text, UTF8ToUTF16("bye ")); | 93 EXPECT_EQ(read_parameters2.text, UTF8ToUTF16("bye ")); |
94 | 94 |
95 FakeMessageArrival(&provider_, read_parameters1); | 95 FakeMessageArrival(&provider_, read_parameters1); |
96 EXPECT_EQ(completion1.completion_count_, 1U); | 96 EXPECT_EQ(completion1.completion_count_, 1U); |
97 EXPECT_EQ(completion2.completion_count_, 0U); | 97 EXPECT_EQ(completion2.completion_count_, 0U); |
98 EXPECT_EQ(provider_.pending_text_request_size(), 1U); | 98 EXPECT_EQ(provider_.pending_text_request_size(), 1U); |
99 | 99 |
100 FakeMessageArrival(&provider_, read_parameters2); | 100 FakeMessageArrival(&provider_, read_parameters2); |
101 EXPECT_EQ(completion1.completion_count_, 1U); | 101 EXPECT_EQ(completion1.completion_count_, 1U); |
102 EXPECT_EQ(completion2.completion_count_, 1U); | 102 EXPECT_EQ(completion2.completion_count_, 1U); |
103 EXPECT_EQ(provider_.pending_text_request_size(), 0U); | 103 EXPECT_EQ(provider_.pending_text_request_size(), 0U); |
104 } | 104 } |
105 | 105 |
106 } // namespace | 106 } // namespace |
OLD | NEW |