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 |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 Loading... |
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 Loading... |
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 |
OLD | NEW |