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

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

Issue 2166683003: Componentize spellcheck [1]: create component and move switches there. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + --no-find-copies Created 4 years, 4 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 (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 |FeedbackSender| object. 5 // Unit tests for |FeedbackSender| object.
6 6
7 #include "chrome/browser/spellchecker/feedback_sender.h" 7 #include "chrome/browser/spellchecker/feedback_sender.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
17 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/spellcheck_common.h" 20 #include "chrome/common/spellcheck_common.h"
22 #include "chrome/common/spellcheck_marker.h" 21 #include "chrome/common/spellcheck_marker.h"
23 #include "chrome/common/spellcheck_result.h" 22 #include "chrome/common/spellcheck_result.h"
24 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
24 #include "components/spellcheck/common/spellcheck_switches.h"
25 #include "components/variations/entropy_provider.h" 25 #include "components/variations/entropy_provider.h"
26 #include "content/public/test/test_browser_thread.h" 26 #include "content/public/test/test_browser_thread.h"
27 #include "net/url_request/test_url_fetcher_factory.h" 27 #include "net/url_request/test_url_fetcher_factory.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
29 29
30 namespace spellcheck { 30 namespace spellcheck {
31 31
32 namespace { 32 namespace {
33 33
34 const char kCountry[] = "USA"; 34 const char kCountry[] = "USA";
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 ~FeedbackSenderTest() override {} 105 ~FeedbackSenderTest() override {}
106 106
107 protected: 107 protected:
108 // Appends the "--enable-spelling-service-feedback" switch to the 108 // Appends the "--enable-spelling-service-feedback" switch to the
109 // command-line. 109 // command-line.
110 void AppendCommandLineSwitch() { 110 void AppendCommandLineSwitch() {
111 // The command-line switch is temporary. 111 // The command-line switch is temporary.
112 // TODO(rouslan): Remove the command-line switch. http://crbug.com/247726 112 // TODO(rouslan): Remove the command-line switch. http://crbug.com/247726
113 base::CommandLine::ForCurrentProcess()->AppendSwitch( 113 base::CommandLine::ForCurrentProcess()->AppendSwitch(
114 switches::kEnableSpellingFeedbackFieldTrial); 114 spellcheck::switches::kEnableSpellingFeedbackFieldTrial);
115 feedback_.reset(new MockFeedbackSender(NULL, kLanguage, kCountry)); 115 feedback_.reset(new MockFeedbackSender(NULL, kLanguage, kCountry));
116 feedback_->StartFeedbackCollection(); 116 feedback_->StartFeedbackCollection();
117 } 117 }
118 118
119 // Enables the "SpellingServiceFeedback.Enabled" field trial. 119 // Enables the "SpellingServiceFeedback.Enabled" field trial.
120 void EnableFieldTrial() { 120 void EnableFieldTrial() {
121 // The field trial is temporary. 121 // The field trial is temporary.
122 // TODO(rouslan): Remove the field trial. http://crbug.com/247726 122 // TODO(rouslan): Remove the field trial. http://crbug.com/247726
123 field_trial_list_.reset( 123 field_trial_list_.reset(
124 new base::FieldTrialList(new metrics::SHA1EntropyProvider("foo"))); 124 new base::FieldTrialList(new metrics::SHA1EntropyProvider("foo")));
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 "the chance to work hard at work worth doing."), 720 "the chance to work hard at work worth doing."),
721 std::vector<SpellCheckMarker>(), &results); 721 std::vector<SpellCheckMarker>(), &results);
722 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 722 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
723 std::vector<uint32_t>()); 723 std::vector<uint32_t>());
724 EXPECT_TRUE( 724 EXPECT_TRUE(
725 UploadDataContains(",\"originalText\":\"and away teh best prize\",")); 725 UploadDataContains(",\"originalText\":\"and away teh best prize\","));
726 EXPECT_TRUE(UploadDataContains(",\"misspelledStart\":9,")); 726 EXPECT_TRUE(UploadDataContains(",\"misspelledStart\":9,"));
727 } 727 }
728 728
729 } // namespace spellcheck 729 } // namespace spellcheck
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/feedback_sender.cc ('k') | chrome/browser/spellchecker/spellcheck_platform_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698