| 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 // Unit tests for |Feedback| object. | 5 // Unit tests for |Feedback| object. |
| 6 | 6 |
| 7 #include "chrome/browser/spellchecker/feedback.h" | 7 #include "chrome/browser/spellchecker/feedback.h" |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 using base::ASCIIToUTF16; | 12 using base::ASCIIToUTF16; |
| 13 | 13 |
| 14 namespace spellcheck { | 14 namespace spellcheck { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Identifier for a renderer process. | 18 // Identifier for a renderer process. |
| 19 const int kRendererProcessId = 7; | 19 const int kRendererProcessId = 7; |
| 20 | 20 |
| 21 // Hash identifier for a misspelling. | 21 // Hash identifier for a misspelling. |
| 22 const uint32 kMisspellingHash = 42; | 22 const uint32 kMisspellingHash = 42; |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 // A test fixture to help keep the tests simple. | 26 // A test fixture to help keep the tests simple. |
| 27 class FeedbackTest : public testing::Test { | 27 class FeedbackTest : public testing::Test { |
| 28 public: | 28 public: |
| 29 FeedbackTest() {} | 29 FeedbackTest() {} |
| 30 virtual ~FeedbackTest() {} | 30 ~FeedbackTest() override {} |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 void AddMisspelling(int renderer_process_id, uint32 hash) { | 33 void AddMisspelling(int renderer_process_id, uint32 hash) { |
| 34 Misspelling misspelling; | 34 Misspelling misspelling; |
| 35 misspelling.hash = hash; | 35 misspelling.hash = hash; |
| 36 feedback_.AddMisspelling(renderer_process_id, misspelling); | 36 feedback_.AddMisspelling(renderer_process_id, misspelling); |
| 37 } | 37 } |
| 38 | 38 |
| 39 spellcheck::Feedback feedback_; | 39 spellcheck::Feedback feedback_; |
| 40 }; | 40 }; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 kMisspellingStart, | 250 kMisspellingStart, |
| 251 kMisspellingLength, | 251 kMisspellingLength, |
| 252 std::vector<base::string16>(1, kSuggestion), | 252 std::vector<base::string16>(1, kSuggestion), |
| 253 kMisspellingHash)); | 253 kMisspellingHash)); |
| 254 feedback_.GetMisspelling(kMisspellingHash)->action.Finalize(); | 254 feedback_.GetMisspelling(kMisspellingHash)->action.Finalize(); |
| 255 feedback_.EraseFinalizedMisspellings(kRendererProcessId); | 255 feedback_.EraseFinalizedMisspellings(kRendererProcessId); |
| 256 EXPECT_TRUE(feedback_.FindMisspellings(kMisspelledWord).empty()); | 256 EXPECT_TRUE(feedback_.FindMisspellings(kMisspelledWord).empty()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace spellcheck | 259 } // namespace spellcheck |
| OLD | NEW |