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

Side by Side Diff: components/spellcheck/renderer/spellcheck_provider_mac_unittest.cc

Issue 2671263003: Merge 3004: Revert of Remove ScopedVector in components/spellcheck (patchset #5 id:80001 of https:/… (Closed)
Patch Set: Created 3 years, 10 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 "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 22 matching lines...) Expand all
33 FakeTextCheckingCompletion completion; 33 FakeTextCheckingCompletion completion;
34 34
35 provider_.RequestTextChecking(base::ASCIIToUTF16("hello "), &completion, 35 provider_.RequestTextChecking(base::ASCIIToUTF16("hello "), &completion,
36 std::vector<SpellCheckMarker>()); 36 std::vector<SpellCheckMarker>());
37 EXPECT_EQ(completion.completion_count_, 0U); 37 EXPECT_EQ(completion.completion_count_, 0U);
38 EXPECT_EQ(provider_.messages_.size(), 1U); 38 EXPECT_EQ(provider_.messages_.size(), 1U);
39 EXPECT_EQ(provider_.pending_text_request_size(), 1U); 39 EXPECT_EQ(provider_.pending_text_request_size(), 1U);
40 40
41 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1; 41 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1;
42 bool ok = SpellCheckHostMsg_RequestTextCheck::Read( 42 bool ok = SpellCheckHostMsg_RequestTextCheck::Read(
43 provider_.messages_[0].get(), &read_parameters1); 43 provider_.messages_[0], &read_parameters1);
44 EXPECT_TRUE(ok); 44 EXPECT_TRUE(ok);
45 EXPECT_EQ(std::get<2>(read_parameters1), base::ASCIIToUTF16("hello ")); 45 EXPECT_EQ(std::get<2>(read_parameters1), base::ASCIIToUTF16("hello "));
46 46
47 FakeMessageArrival(&provider_, read_parameters1); 47 FakeMessageArrival(&provider_, read_parameters1);
48 EXPECT_EQ(completion.completion_count_, 1U); 48 EXPECT_EQ(completion.completion_count_, 1U);
49 EXPECT_EQ(provider_.pending_text_request_size(), 0U); 49 EXPECT_EQ(provider_.pending_text_request_size(), 0U);
50 } 50 }
51 51
52 TEST_F(SpellCheckProviderMacTest, TwoRoundtripSuccess) { 52 TEST_F(SpellCheckProviderMacTest, TwoRoundtripSuccess) {
53 FakeTextCheckingCompletion completion1; 53 FakeTextCheckingCompletion completion1;
54 provider_.RequestTextChecking(base::ASCIIToUTF16("hello "), &completion1, 54 provider_.RequestTextChecking(base::ASCIIToUTF16("hello "), &completion1,
55 std::vector<SpellCheckMarker>()); 55 std::vector<SpellCheckMarker>());
56 FakeTextCheckingCompletion completion2; 56 FakeTextCheckingCompletion completion2;
57 provider_.RequestTextChecking(base::ASCIIToUTF16("bye "), &completion2, 57 provider_.RequestTextChecking(base::ASCIIToUTF16("bye "), &completion2,
58 std::vector<SpellCheckMarker>()); 58 std::vector<SpellCheckMarker>());
59 59
60 EXPECT_EQ(completion1.completion_count_, 0U); 60 EXPECT_EQ(completion1.completion_count_, 0U);
61 EXPECT_EQ(completion2.completion_count_, 0U); 61 EXPECT_EQ(completion2.completion_count_, 0U);
62 EXPECT_EQ(provider_.messages_.size(), 2U); 62 EXPECT_EQ(provider_.messages_.size(), 2U);
63 EXPECT_EQ(provider_.pending_text_request_size(), 2U); 63 EXPECT_EQ(provider_.pending_text_request_size(), 2U);
64 64
65 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1; 65 SpellCheckHostMsg_RequestTextCheck::Param read_parameters1;
66 bool ok = SpellCheckHostMsg_RequestTextCheck::Read( 66 bool ok = SpellCheckHostMsg_RequestTextCheck::Read(
67 provider_.messages_[0].get(), &read_parameters1); 67 provider_.messages_[0], &read_parameters1);
68 EXPECT_TRUE(ok); 68 EXPECT_TRUE(ok);
69 EXPECT_EQ(std::get<2>(read_parameters1), base::UTF8ToUTF16("hello ")); 69 EXPECT_EQ(std::get<2>(read_parameters1), base::UTF8ToUTF16("hello "));
70 70
71 SpellCheckHostMsg_RequestTextCheck::Param read_parameters2; 71 SpellCheckHostMsg_RequestTextCheck::Param read_parameters2;
72 ok = SpellCheckHostMsg_RequestTextCheck::Read(provider_.messages_[1].get(), 72 ok = SpellCheckHostMsg_RequestTextCheck::Read(
73 &read_parameters2); 73 provider_.messages_[1], &read_parameters2);
74 EXPECT_TRUE(ok); 74 EXPECT_TRUE(ok);
75 EXPECT_EQ(std::get<2>(read_parameters2), base::UTF8ToUTF16("bye ")); 75 EXPECT_EQ(std::get<2>(read_parameters2), base::UTF8ToUTF16("bye "));
76 76
77 FakeMessageArrival(&provider_, read_parameters1); 77 FakeMessageArrival(&provider_, read_parameters1);
78 EXPECT_EQ(completion1.completion_count_, 1U); 78 EXPECT_EQ(completion1.completion_count_, 1U);
79 EXPECT_EQ(completion2.completion_count_, 0U); 79 EXPECT_EQ(completion2.completion_count_, 0U);
80 EXPECT_EQ(provider_.pending_text_request_size(), 1U); 80 EXPECT_EQ(provider_.pending_text_request_size(), 1U);
81 81
82 FakeMessageArrival(&provider_, read_parameters2); 82 FakeMessageArrival(&provider_, read_parameters2);
83 EXPECT_EQ(completion1.completion_count_, 1U); 83 EXPECT_EQ(completion1.completion_count_, 1U);
84 EXPECT_EQ(completion2.completion_count_, 1U); 84 EXPECT_EQ(completion2.completion_count_, 1U);
85 EXPECT_EQ(provider_.pending_text_request_size(), 0U); 85 EXPECT_EQ(provider_.pending_text_request_size(), 0U);
86 } 86 }
87 87
88 } // namespace 88 } // namespace
OLDNEW
« no previous file with comments | « components/spellcheck/renderer/spellcheck.cc ('k') | components/spellcheck/renderer/spellcheck_provider_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698