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/spellcheck_common.h" | |
21 #include "chrome/common/spellcheck_marker.h" | |
22 #include "chrome/common/spellcheck_result.h" | |
23 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 21 #include "components/spellcheck/common/spellcheck_common.h" |
| 22 #include "components/spellcheck/common/spellcheck_marker.h" |
| 23 #include "components/spellcheck/common/spellcheck_result.h" |
24 #include "components/spellcheck/common/spellcheck_switches.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 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 feedback_->OnSpellcheckResults(kRendererProcessId, | 134 feedback_->OnSpellcheckResults(kRendererProcessId, |
135 base::UTF8ToUTF16(kText), | 135 base::UTF8ToUTF16(kText), |
136 std::vector<SpellCheckMarker>(), | 136 std::vector<SpellCheckMarker>(), |
137 &results); | 137 &results); |
138 return results[0].hash; | 138 return results[0].hash; |
139 } | 139 } |
140 | 140 |
141 void ExpireSession() { | 141 void ExpireSession() { |
142 feedback_->session_start_ = | 142 feedback_->session_start_ = |
143 base::Time::Now() - | 143 base::Time::Now() - |
144 base::TimeDelta::FromHours(chrome::spellcheck_common::kSessionHours); | 144 base::TimeDelta::FromHours(spellcheck::kSessionHours); |
145 } | 145 } |
146 | 146 |
147 bool UploadDataContains(const std::string& data) const { | 147 bool UploadDataContains(const std::string& data) const { |
148 const net::TestURLFetcher* fetcher = | 148 const net::TestURLFetcher* fetcher = |
149 fetchers_.GetFetcherByID(kUrlFetcherId); | 149 fetchers_.GetFetcherByID(kUrlFetcherId); |
150 return fetcher && CountOccurences(fetcher->upload_data(), data) > 0; | 150 return fetcher && CountOccurences(fetcher->upload_data(), data) > 0; |
151 } | 151 } |
152 | 152 |
153 bool UploadDataContains(const std::string& data, | 153 bool UploadDataContains(const std::string& data, |
154 int number_of_occurrences) const { | 154 int number_of_occurrences) const { |
(...skipping 565 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 |