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

Side by Side Diff: chrome/browser/spellchecker/spell_check_host_impl_unittest.cc

Issue 2911253003: [Reland] Allow storing multiple replacements on SpellCheckResult (Closed)
Patch Set: Fix typo Created 3 years, 6 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/spellchecker/spell_check_host_impl.h" 5 #include "chrome/browser/spellchecker/spell_check_host_impl.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 base::ASCIIToUTF16("World"))); 56 base::ASCIIToUTF16("World")));
57 TestSpellCheckHostImpl host_impl; 57 TestSpellCheckHostImpl host_impl;
58 host_impl.GetCustomDictionary().AddWord("Helllo"); 58 host_impl.GetCustomDictionary().AddWord("Helllo");
59 std::vector<SpellCheckResult> results = 59 std::vector<SpellCheckResult> results =
60 host_impl.FilterCustomWordResults("Helllo Warld", service_results); 60 host_impl.FilterCustomWordResults("Helllo Warld", service_results);
61 ASSERT_EQ(1u, results.size()); 61 ASSERT_EQ(1u, results.size());
62 62
63 EXPECT_EQ(service_results[1].decoration, results[0].decoration); 63 EXPECT_EQ(service_results[1].decoration, results[0].decoration);
64 EXPECT_EQ(service_results[1].location, results[0].location); 64 EXPECT_EQ(service_results[1].location, results[0].location);
65 EXPECT_EQ(service_results[1].length, results[0].length); 65 EXPECT_EQ(service_results[1].length, results[0].length);
66 EXPECT_EQ(service_results[1].replacement, results[0].replacement); 66 EXPECT_EQ(service_results[1].replacements.size(),
67 results[0].replacements.size());
68 EXPECT_EQ(service_results[1].replacements[0], results[0].replacements[0]);
67 } 69 }
68 70
69 // Spelling corrections of words that are not in the custom dictionary should 71 // Spelling corrections of words that are not in the custom dictionary should
70 // be retained in the results returned by the remote Spelling service. 72 // be retained in the results returned by the remote Spelling service.
71 TEST(SpellCheckHostImplTest, SpellingServiceResults) { 73 TEST(SpellCheckHostImplTest, SpellingServiceResults) {
72 std::vector<SpellCheckResult> service_results; 74 std::vector<SpellCheckResult> service_results;
73 service_results.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 0, 6, 75 service_results.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 0, 6,
74 base::ASCIIToUTF16("Hello"))); 76 base::ASCIIToUTF16("Hello")));
75 service_results.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 7, 5, 77 service_results.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 7, 5,
76 base::ASCIIToUTF16("World"))); 78 base::ASCIIToUTF16("World")));
77 TestSpellCheckHostImpl host_impl; 79 TestSpellCheckHostImpl host_impl;
78 host_impl.GetCustomDictionary().AddWord("Hulo"); 80 host_impl.GetCustomDictionary().AddWord("Hulo");
79 std::vector<SpellCheckResult> results = 81 std::vector<SpellCheckResult> results =
80 host_impl.FilterCustomWordResults("Helllo Warld", service_results); 82 host_impl.FilterCustomWordResults("Helllo Warld", service_results);
81 ASSERT_EQ(service_results.size(), results.size()); 83 ASSERT_EQ(service_results.size(), results.size());
82 84
83 for (size_t i = 0; i < results.size(); ++i) { 85 for (size_t i = 0; i < results.size(); ++i) {
84 EXPECT_EQ(service_results[i].decoration, results[i].decoration); 86 EXPECT_EQ(service_results[i].decoration, results[i].decoration);
85 EXPECT_EQ(service_results[i].location, results[i].location); 87 EXPECT_EQ(service_results[i].location, results[i].location);
86 EXPECT_EQ(service_results[i].length, results[i].length); 88 EXPECT_EQ(service_results[i].length, results[i].length);
87 EXPECT_EQ(service_results[i].replacement, results[i].replacement); 89 EXPECT_EQ(service_results[i].replacements.size(),
90 results[i].replacements.size());
91 EXPECT_EQ(service_results[i].replacements, results[i].replacements);
Noel Gordon 2017/05/31 05:46:21 x[i].replacements -> x[i].replacements[0] here I t
88 } 92 }
89 } 93 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698