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

Side by Side Diff: components/spellcheck/browser/feedback_sender_unittest.cc

Issue 2244083002: Componentize spellcheck [4]: spellcheck/browser and android java-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 "components/spellcheck/browser/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/test/base/testing_profile.h"
21 #include "components/spellcheck/common/spellcheck_common.h" 20 #include "components/spellcheck/common/spellcheck_common.h"
22 #include "components/spellcheck/common/spellcheck_marker.h" 21 #include "components/spellcheck/common/spellcheck_marker.h"
23 #include "components/spellcheck/common/spellcheck_result.h" 22 #include "components/spellcheck/common/spellcheck_result.h"
24 #include "components/spellcheck/common/spellcheck_switches.h" 23 #include "components/spellcheck/common/spellcheck_switches.h"
25 #include "components/variations/entropy_provider.h" 24 #include "components/variations/entropy_provider.h"
26 #include "content/public/test/test_browser_thread.h" 25 #include "content/public/test/test_browser_thread.h"
27 #include "net/url_request/test_url_fetcher_factory.h" 26 #include "net/url_request/test_url_fetcher_factory.h"
28 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
29 28
30 namespace spellcheck { 29 namespace spellcheck {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 174 }
176 175
177 void AdjustUpdateTime(base::TimeDelta offset) { 176 void AdjustUpdateTime(base::TimeDelta offset) {
178 feedback_->last_salt_update_ += offset; 177 feedback_->last_salt_update_ += offset;
179 } 178 }
180 179
181 std::unique_ptr<MockFeedbackSender> feedback_; 180 std::unique_ptr<MockFeedbackSender> feedback_;
182 181
183 private: 182 private:
184 base::MessageLoop loop_; 183 base::MessageLoop loop_;
185 TestingProfile profile_;
186 content::TestBrowserThread ui_thread_; 184 content::TestBrowserThread ui_thread_;
187 std::unique_ptr<base::FieldTrialList> field_trial_list_; 185 std::unique_ptr<base::FieldTrialList> field_trial_list_;
188 scoped_refptr<base::FieldTrial> field_trial_; 186 scoped_refptr<base::FieldTrial> field_trial_;
189 net::TestURLFetcherFactory fetchers_; 187 net::TestURLFetcherFactory fetchers_;
190 }; 188 };
191 189
192 // Do not send data if there's no feedback. 190 // Do not send data if there's no feedback.
193 TEST_F(FeedbackSenderTest, NoFeedback) { 191 TEST_F(FeedbackSenderTest, NoFeedback) {
194 EXPECT_FALSE(IsUploadingData()); 192 EXPECT_FALSE(IsUploadingData());
195 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 193 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 "the chance to work hard at work worth doing."), 718 "the chance to work hard at work worth doing."),
721 std::vector<SpellCheckMarker>(), &results); 719 std::vector<SpellCheckMarker>(), &results);
722 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 720 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
723 std::vector<uint32_t>()); 721 std::vector<uint32_t>());
724 EXPECT_TRUE( 722 EXPECT_TRUE(
725 UploadDataContains(",\"originalText\":\"and away teh best prize\",")); 723 UploadDataContains(",\"originalText\":\"and away teh best prize\","));
726 EXPECT_TRUE(UploadDataContains(",\"misspelledStart\":9,")); 724 EXPECT_TRUE(UploadDataContains(",\"misspelledStart\":9,"));
727 } 725 }
728 726
729 } // namespace spellcheck 727 } // namespace spellcheck
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698