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 "base/json/json_reader.h" | 5 #include "base/json/json_reader.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/spellchecker/misspelling.h" | 8 #include "chrome/browser/spellchecker/misspelling.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 TEST(MisspellingTest, SerializeTest) { | 11 TEST(MisspellingTest, SerializeTest) { |
12 Misspelling misspelling; | 12 Misspelling misspelling; |
13 misspelling.context = ASCIIToUTF16("How doe sit know"); | 13 misspelling.context = ASCIIToUTF16("How doe sit know"); |
14 misspelling.location = 4; | 14 misspelling.location = 4; |
15 misspelling.length = 7; | 15 misspelling.length = 7; |
16 misspelling.timestamp = base::Time::FromJsTime(42); | 16 misspelling.timestamp = base::Time::FromJsTime(42); |
17 misspelling.hash = 9001; | 17 misspelling.hash = 9001; |
18 misspelling.suggestions.push_back(ASCIIToUTF16("does it")); | 18 misspelling.suggestions.push_back(ASCIIToUTF16("does it")); |
19 | 19 |
20 scoped_ptr<base::Value> expected(base::JSONReader::Read( | 20 scoped_ptr<base::Value> expected(base::JSONReader::Read( |
21 "{\"originalText\": \"How doe sit know\"," | 21 "{\"originalText\": \"How doe sit know\"," |
22 "\"misspelledStart\": 4," | 22 "\"misspelledStart\": 4," |
23 "\"misspelledLength\": 7," | 23 "\"misspelledLength\": 7," |
24 "\"timestamp\": \"42\"," | 24 "\"timestamp\": \"42\"," |
25 "\"suggestionId\":\"9001\"," | 25 "\"suggestionId\":\"9001\"," |
26 "\"suggestions\": [\"does it\"]," | 26 "\"suggestions\": [\"does it\"]," |
27 "\"userActions\": [{\"actionType\": \"PENDING\"}]}")); | 27 "\"userActions\": [{\"actionType\": \"PENDING\"}]}")); |
28 | 28 |
29 scoped_ptr<base::DictionaryValue> serialized(misspelling.Serialize()); | 29 scoped_ptr<base::DictionaryValue> serialized(misspelling.Serialize()); |
30 EXPECT_TRUE(serialized->Equals(expected.get())); | 30 EXPECT_TRUE(serialized->Equals(expected.get())); |
31 } | 31 } |
OLD | NEW |