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