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

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

Issue 15934002: Add IN_DICTIONARY feedback type for spelling service (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 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
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_action.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/spellchecker/spellcheck_action.h" 10 #include "chrome/browser/spellchecker/spellcheck_action.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 TEST(SpellcheckActionTest, FinalActionsTest) { 13 TEST(SpellcheckActionTest, FinalActionsTest) {
14 static const SpellcheckAction::SpellcheckActionType kFinalActions[] = { 14 static const SpellcheckAction::SpellcheckActionType kFinalActions[] = {
15 SpellcheckAction::TYPE_ADD_TO_DICT, 15 SpellcheckAction::TYPE_ADD_TO_DICT,
16 SpellcheckAction::TYPE_IGNORE, 16 SpellcheckAction::TYPE_IGNORE,
17 SpellcheckAction::TYPE_IN_DICTIONARY,
17 SpellcheckAction::TYPE_MANUALLY_CORRECTED, 18 SpellcheckAction::TYPE_MANUALLY_CORRECTED,
18 SpellcheckAction::TYPE_NO_ACTION, 19 SpellcheckAction::TYPE_NO_ACTION,
19 SpellcheckAction::TYPE_SELECT, 20 SpellcheckAction::TYPE_SELECT,
20 }; 21 };
21 SpellcheckAction action; 22 SpellcheckAction action;
22 for (size_t i = 0; i < arraysize(kFinalActions); ++i) { 23 for (size_t i = 0; i < arraysize(kFinalActions); ++i) {
23 action.type = kFinalActions[i]; 24 action.type = kFinalActions[i];
24 ASSERT_TRUE(action.IsFinal()); 25 ASSERT_TRUE(action.IsFinal());
25 } 26 }
26 } 27 }
(...skipping 27 matching lines...) Expand all
54 SpellcheckAction action; 55 SpellcheckAction action;
55 std::string expected; 56 std::string expected;
56 } kTestCases[] = { 57 } kTestCases[] = {
57 { SpellcheckAction( 58 { SpellcheckAction(
58 SpellcheckAction::TYPE_ADD_TO_DICT, -1, ASCIIToUTF16("nothing")), 59 SpellcheckAction::TYPE_ADD_TO_DICT, -1, ASCIIToUTF16("nothing")),
59 "{\"actionType\": \"ADD_TO_DICT\"}" }, 60 "{\"actionType\": \"ADD_TO_DICT\"}" },
60 { SpellcheckAction( 61 { SpellcheckAction(
61 SpellcheckAction::TYPE_IGNORE, -1, ASCIIToUTF16("nothing")), 62 SpellcheckAction::TYPE_IGNORE, -1, ASCIIToUTF16("nothing")),
62 "{\"actionType\": \"IGNORE\"}" }, 63 "{\"actionType\": \"IGNORE\"}" },
63 { SpellcheckAction( 64 { SpellcheckAction(
65 SpellcheckAction::TYPE_IN_DICTIONARY, -1, ASCIIToUTF16("nothing")),
66 "{\"actionType\": \"IN_DICTIONARY\"}" },
67 { SpellcheckAction(
64 SpellcheckAction::TYPE_MANUALLY_CORRECTED, -1, ASCIIToUTF16("hello")), 68 SpellcheckAction::TYPE_MANUALLY_CORRECTED, -1, ASCIIToUTF16("hello")),
65 "{\"actionTargetValue\": \"hello\"," 69 "{\"actionTargetValue\": \"hello\","
66 "\"actionType\": \"MANUALLY_CORRECTED\"}" }, 70 "\"actionType\": \"MANUALLY_CORRECTED\"}" },
67 { SpellcheckAction( 71 { SpellcheckAction(
68 SpellcheckAction::TYPE_NO_ACTION, -1, ASCIIToUTF16("nothing")), 72 SpellcheckAction::TYPE_NO_ACTION, -1, ASCIIToUTF16("nothing")),
69 "{\"actionType\": \"NO_ACTION\"}" }, 73 "{\"actionType\": \"NO_ACTION\"}" },
70 { SpellcheckAction( 74 { SpellcheckAction(
71 SpellcheckAction::TYPE_PENDING, -1, ASCIIToUTF16("nothing")), 75 SpellcheckAction::TYPE_PENDING, -1, ASCIIToUTF16("nothing")),
72 "{\"actionType\": \"PENDING\"}" }, 76 "{\"actionType\": \"PENDING\"}" },
73 { SpellcheckAction( 77 { SpellcheckAction(
74 SpellcheckAction::TYPE_PENDING_IGNORE, -1, ASCIIToUTF16("nothing")), 78 SpellcheckAction::TYPE_PENDING_IGNORE, -1, ASCIIToUTF16("nothing")),
75 "{\"actionType\": \"PENDING\"}" }, 79 "{\"actionType\": \"PENDING\"}" },
76 { SpellcheckAction( 80 { SpellcheckAction(
77 SpellcheckAction::TYPE_SELECT, 42, ASCIIToUTF16("nothing")), 81 SpellcheckAction::TYPE_SELECT, 42, ASCIIToUTF16("nothing")),
78 "{\"actionTargetIndex\": 42, \"actionType\": \"SELECT\"}" }, 82 "{\"actionTargetIndex\": 42, \"actionType\": \"SELECT\"}" },
79 }; 83 };
80 for (size_t i = 0; i < kNumTestCases; ++i) { 84 for (size_t i = 0; i < kNumTestCases; ++i) {
81 scoped_ptr<base::DictionaryValue> serialized( 85 scoped_ptr<base::DictionaryValue> serialized(
82 kTestCases[i].action.Serialize()); 86 kTestCases[i].action.Serialize());
83 scoped_ptr<base::Value> expected( 87 scoped_ptr<base::Value> expected(
84 base::JSONReader::Read(kTestCases[i].expected)); 88 base::JSONReader::Read(kTestCases[i].expected));
85 EXPECT_TRUE(serialized->Equals(expected.get())); 89 EXPECT_TRUE(serialized->Equals(expected.get()));
86 } 90 }
87 } 91 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_action.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698