OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/feedback.h" | 5 #include "chrome/browser/spellchecker/feedback.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" |
7 | 7 |
8 namespace spellcheck { | 8 namespace spellcheck { |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 Misspelling* removed_misspelling = | 52 Misspelling* removed_misspelling = |
53 feedback_.GetMisspelling(kRemovedMisspellingHash); | 53 feedback_.GetMisspelling(kRemovedMisspellingHash); |
54 EXPECT_NE(static_cast<Misspelling*>(NULL), removed_misspelling); | 54 EXPECT_NE(static_cast<Misspelling*>(NULL), removed_misspelling); |
55 EXPECT_TRUE(removed_misspelling->action.IsFinal()); | 55 EXPECT_TRUE(removed_misspelling->action.IsFinal()); |
56 Misspelling* remaining_misspelling = | 56 Misspelling* remaining_misspelling = |
57 feedback_.GetMisspelling(kRemainingMisspellingHash); | 57 feedback_.GetMisspelling(kRemainingMisspellingHash); |
58 EXPECT_NE(static_cast<Misspelling*>(NULL), remaining_misspelling); | 58 EXPECT_NE(static_cast<Misspelling*>(NULL), remaining_misspelling); |
59 EXPECT_FALSE(remaining_misspelling->action.IsFinal()); | 59 EXPECT_FALSE(remaining_misspelling->action.IsFinal()); |
60 } | 60 } |
61 | 61 |
62 // Duplicate misspellings should not be finalized. | |
63 TEST_F(FeedbackTest, DuplicateMisspellingFinalization) { | |
groby-ooo-7-16
2013/05/23 19:10:50
Why a new test?
please use gerrit instead
2013/05/23 19:50:47
This test verifies that I fixed a bug. If Feedback
| |
64 AddMisspelling(kRendererProcessId, kMisspellingHash); | |
65 AddMisspelling(kRendererProcessId, kMisspellingHash); | |
66 std::vector<uint32> remaining_markers(1, kMisspellingHash); | |
67 feedback_.FinalizeRemovedMisspellings(kRendererProcessId, remaining_markers); | |
68 std::vector<Misspelling> misspellings = feedback_.GetAllMisspellings(); | |
69 EXPECT_EQ(static_cast<size_t>(1), misspellings.size()); | |
70 EXPECT_FALSE(misspellings[0].action.IsFinal()); | |
71 } | |
72 | |
62 // Misspellings should be associated with a renderer. | 73 // Misspellings should be associated with a renderer. |
63 TEST_F(FeedbackTest, RendererHasMisspellings) { | 74 TEST_F(FeedbackTest, RendererHasMisspellings) { |
64 EXPECT_FALSE(feedback_.RendererHasMisspellings(kRendererProcessId)); | 75 EXPECT_FALSE(feedback_.RendererHasMisspellings(kRendererProcessId)); |
65 AddMisspelling(kRendererProcessId, kMisspellingHash); | 76 AddMisspelling(kRendererProcessId, kMisspellingHash); |
66 EXPECT_TRUE(feedback_.RendererHasMisspellings(kRendererProcessId)); | 77 EXPECT_TRUE(feedback_.RendererHasMisspellings(kRendererProcessId)); |
67 } | 78 } |
68 | 79 |
69 // Should be able to retrieve misspellings in renderer. | 80 // Should be able to retrieve misspellings in renderer. |
70 TEST_F(FeedbackTest, GetMisspellingsInRenderer) { | 81 TEST_F(FeedbackTest, GetMisspellingsInRenderer) { |
71 AddMisspelling(kRendererProcessId, kMisspellingHash); | 82 AddMisspelling(kRendererProcessId, kMisspellingHash); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 // Should be able to clear all misspellings. | 167 // Should be able to clear all misspellings. |
157 TEST_F(FeedbackTest, ClearFeedback) { | 168 TEST_F(FeedbackTest, ClearFeedback) { |
158 AddMisspelling(kRendererProcessId, kMisspellingHash); | 169 AddMisspelling(kRendererProcessId, kMisspellingHash); |
159 AddMisspelling(kRendererProcessId + 1, kMisspellingHash + 1); | 170 AddMisspelling(kRendererProcessId + 1, kMisspellingHash + 1); |
160 EXPECT_FALSE(feedback_.Empty()); | 171 EXPECT_FALSE(feedback_.Empty()); |
161 feedback_.Clear(); | 172 feedback_.Clear(); |
162 EXPECT_TRUE(feedback_.Empty()); | 173 EXPECT_TRUE(feedback_.Empty()); |
163 } | 174 } |
164 | 175 |
165 } // namespace spellcheck | 176 } // namespace spellcheck |
OLD | NEW |