Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: chrome/renderer/spellchecker/spellcheck_provider_mac_unittest.cc

Issue 2177023002: Remove spellchecker feedback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/renderer/spellchecker/spellcheck_provider_test.h" 9 #include "chrome/renderer/spellchecker/spellcheck_provider_test.h"
10 #include "components/spellcheck/common/spellcheck_marker.h"
11 #include "components/spellcheck/common/spellcheck_messages.h" 10 #include "components/spellcheck/common/spellcheck_messages.h"
12 #include "components/spellcheck/common/spellcheck_result.h" 11 #include "components/spellcheck/common/spellcheck_result.h"
13 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
14 #include "third_party/WebKit/public/platform/WebString.h" 13 #include "third_party/WebKit/public/platform/WebString.h"
15 14
16 namespace { 15 namespace {
17 16
18 class SpellCheckProviderMacTest : public SpellCheckProviderTest {}; 17 class SpellCheckProviderMacTest : public SpellCheckProviderTest {};
19 18
20 void FakeMessageArrival( 19 void FakeMessageArrival(
21 SpellCheckProvider* provider, 20 SpellCheckProvider* provider,
22 const SpellCheckHostMsg_RequestTextCheck::Param& parameters) { 21 const SpellCheckHostMsg_RequestTextCheck::Param& parameters) {
23 std::vector<SpellCheckResult> fake_result; 22 std::vector<SpellCheckResult> fake_result;
24 bool handled = provider->OnMessageReceived( 23 bool handled = provider->OnMessageReceived(
25 SpellCheckMsg_RespondTextCheck( 24 SpellCheckMsg_RespondTextCheck(
26 0, 25 0,
27 std::get<1>(parameters), 26 std::get<1>(parameters),
28 base::ASCIIToUTF16("test"), 27 base::ASCIIToUTF16("test"),
29 fake_result)); 28 fake_result));
30 EXPECT_TRUE(handled); 29 EXPECT_TRUE(handled);
31 } 30 }
32 31
33 TEST_F(SpellCheckProviderMacTest, SingleRoundtripSuccess) { 32 TEST_F(SpellCheckProviderMacTest, SingleRoundtripSuccess) {
34 FakeTextCheckingCompletion completion; 33 FakeTextCheckingCompletion completion;
35 34
36 provider_.RequestTextChecking(blink::WebString("hello "), 35 provider_.RequestTextChecking(blink::WebString("hello "), &completion);
37 &completion,
38 std::vector<SpellCheckMarker>());
39 EXPECT_EQ(completion.completion_count_, 0U); 36 EXPECT_EQ(completion.completion_count_, 0U);
40 EXPECT_EQ(provider_.messages_.size(), 1U); 37 EXPECT_EQ(provider_.messages_.size(), 1U);
41 EXPECT_EQ(provider_.pending_text_request_size(), 1U); 38 EXPECT_EQ(provider_.pending_text_request_size(), 1U);
42 39
43 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1; 40 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1;
44 bool ok = SpellCheckHostMsg_RequestTextCheck::Read( 41 bool ok = SpellCheckHostMsg_RequestTextCheck::Read(
45 provider_.messages_[0], &read_parameters1); 42 provider_.messages_[0], &read_parameters1);
46 EXPECT_TRUE(ok); 43 EXPECT_TRUE(ok);
47 EXPECT_EQ(std::get<2>(read_parameters1), base::UTF8ToUTF16("hello ")); 44 EXPECT_EQ(std::get<2>(read_parameters1), base::UTF8ToUTF16("hello "));
48 45
49 FakeMessageArrival(&provider_, read_parameters1); 46 FakeMessageArrival(&provider_, read_parameters1);
50 EXPECT_EQ(completion.completion_count_, 1U); 47 EXPECT_EQ(completion.completion_count_, 1U);
51 EXPECT_EQ(provider_.pending_text_request_size(), 0U); 48 EXPECT_EQ(provider_.pending_text_request_size(), 0U);
52 } 49 }
53 50
54 TEST_F(SpellCheckProviderMacTest, TwoRoundtripSuccess) { 51 TEST_F(SpellCheckProviderMacTest, TwoRoundtripSuccess) {
55 FakeTextCheckingCompletion completion1; 52 FakeTextCheckingCompletion completion1;
56 provider_.RequestTextChecking(blink::WebString("hello "), 53 provider_.RequestTextChecking(blink::WebString("hello "), &completion1);
57 &completion1,
58 std::vector<SpellCheckMarker>());
59 FakeTextCheckingCompletion completion2; 54 FakeTextCheckingCompletion completion2;
60 provider_.RequestTextChecking(blink::WebString("bye "), 55 provider_.RequestTextChecking(blink::WebString("bye "), &completion2);
61 &completion2,
62 std::vector<SpellCheckMarker>());
63 56
64 EXPECT_EQ(completion1.completion_count_, 0U); 57 EXPECT_EQ(completion1.completion_count_, 0U);
65 EXPECT_EQ(completion2.completion_count_, 0U); 58 EXPECT_EQ(completion2.completion_count_, 0U);
66 EXPECT_EQ(provider_.messages_.size(), 2U); 59 EXPECT_EQ(provider_.messages_.size(), 2U);
67 EXPECT_EQ(provider_.pending_text_request_size(), 2U); 60 EXPECT_EQ(provider_.pending_text_request_size(), 2U);
68 61
69 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1; 62 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1;
70 bool ok = SpellCheckHostMsg_RequestTextCheck::Read( 63 bool ok = SpellCheckHostMsg_RequestTextCheck::Read(
71 provider_.messages_[0], &read_parameters1); 64 provider_.messages_[0], &read_parameters1);
72 EXPECT_TRUE(ok); 65 EXPECT_TRUE(ok);
(...skipping 10 matching lines...) Expand all
83 EXPECT_EQ(completion2.completion_count_, 0U); 76 EXPECT_EQ(completion2.completion_count_, 0U);
84 EXPECT_EQ(provider_.pending_text_request_size(), 1U); 77 EXPECT_EQ(provider_.pending_text_request_size(), 1U);
85 78
86 FakeMessageArrival(&provider_, read_parameters2); 79 FakeMessageArrival(&provider_, read_parameters2);
87 EXPECT_EQ(completion1.completion_count_, 1U); 80 EXPECT_EQ(completion1.completion_count_, 1U);
88 EXPECT_EQ(completion2.completion_count_, 1U); 81 EXPECT_EQ(completion2.completion_count_, 1U);
89 EXPECT_EQ(provider_.pending_text_request_size(), 0U); 82 EXPECT_EQ(provider_.pending_text_request_size(), 0U);
90 } 83 }
91 84
92 } // namespace 85 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698