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

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

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 years, 3 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 | Annotate | Revision Log
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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/metrics/entropy_provider.h" 18 #include "chrome/common/metrics/entropy_provider.h"
19 #include "chrome/common/spellcheck_common.h" 19 #include "chrome/common/spellcheck_common.h"
20 #include "chrome/common/spellcheck_marker.h" 20 #include "chrome/common/spellcheck_marker.h"
21 #include "chrome/common/spellcheck_result.h" 21 #include "chrome/common/spellcheck_result.h"
22 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
23 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread_bundle.h"
24 #include "net/url_request/test_url_fetcher_factory.h" 24 #include "net/url_request/test_url_fetcher_factory.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 namespace spellcheck { 27 namespace spellcheck {
28 28
29 namespace { 29 namespace {
30 30
31 const char kCountry[] = "USA"; 31 const char kCountry[] = "USA";
32 const char kLanguage[] = "en"; 32 const char kLanguage[] = "en";
33 const char kText[] = "Helllo world."; 33 const char kText[] = "Helllo world.";
(...skipping 20 matching lines...) Expand all
54 ++number_of_occurrences; 54 ++number_of_occurrences;
55 } 55 }
56 return number_of_occurrences; 56 return number_of_occurrences;
57 } 57 }
58 58
59 } // namespace 59 } // namespace
60 60
61 // A test fixture to help keep tests simple. 61 // A test fixture to help keep tests simple.
62 class FeedbackSenderTest : public testing::Test { 62 class FeedbackSenderTest : public testing::Test {
63 public: 63 public:
64 FeedbackSenderTest() : ui_thread_(content::BrowserThread::UI, &loop_) { 64 FeedbackSenderTest() {
65 // The command-line switch and the field trial are temporary. 65 // The command-line switch and the field trial are temporary.
66 // TODO(rouslan): Remove the command-line switch and the field trial. 66 // TODO(rouslan): Remove the command-line switch and the field trial.
67 // http://crbug.com/247726 67 // http://crbug.com/247726
68 CommandLine::ForCurrentProcess()->AppendSwitch( 68 CommandLine::ForCurrentProcess()->AppendSwitch(
69 switches::kEnableSpellingServiceFeedback); 69 switches::kEnableSpellingServiceFeedback);
70 field_trial_list_.reset( 70 field_trial_list_.reset(
71 new base::FieldTrialList(new metrics::SHA1EntropyProvider("foo"))); 71 new base::FieldTrialList(new metrics::SHA1EntropyProvider("foo")));
72 field_trial_ = base::FieldTrialList::CreateFieldTrial( 72 field_trial_ = base::FieldTrialList::CreateFieldTrial(
73 kFeedbackFieldTrialName, kFeedbackFieldTrialEnabledGroupName); 73 kFeedbackFieldTrialName, kFeedbackFieldTrialEnabledGroupName);
74 field_trial_->group(); 74 field_trial_->group();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 std::string GetUploadData() const { 119 std::string GetUploadData() const {
120 const net::TestURLFetcher* fetcher = 120 const net::TestURLFetcher* fetcher =
121 fetchers_.GetFetcherByID(kUrlFetcherId); 121 fetchers_.GetFetcherByID(kUrlFetcherId);
122 return fetcher ? fetcher->upload_data() : std::string(); 122 return fetcher ? fetcher->upload_data() : std::string();
123 } 123 }
124 124
125 scoped_ptr<spellcheck::FeedbackSender> feedback_; 125 scoped_ptr<spellcheck::FeedbackSender> feedback_;
126 126
127 private: 127 private:
128 content::TestBrowserThreadBundle thread_bundle_;
128 TestingProfile profile_; 129 TestingProfile profile_;
129 base::MessageLoop loop_;
130 content::TestBrowserThread ui_thread_;
131 scoped_ptr<base::FieldTrialList> field_trial_list_; 130 scoped_ptr<base::FieldTrialList> field_trial_list_;
132 scoped_refptr<base::FieldTrial> field_trial_; 131 scoped_refptr<base::FieldTrial> field_trial_;
133 net::TestURLFetcherFactory fetchers_; 132 net::TestURLFetcherFactory fetchers_;
134 }; 133 };
135 134
136 // Do not send data if there's no feedback. 135 // Do not send data if there's no feedback.
137 TEST_F(FeedbackSenderTest, NoFeedback) { 136 TEST_F(FeedbackSenderTest, NoFeedback) {
138 EXPECT_FALSE(IsUploadingData()); 137 EXPECT_FALSE(IsUploadingData());
139 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 138 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
140 std::vector<uint32>()); 139 std::vector<uint32>());
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 feedback_->OnSpellcheckResults(kRendererProcessId, 517 feedback_->OnSpellcheckResults(kRendererProcessId,
519 UTF8ToUTF16(kText), 518 UTF8ToUTF16(kText),
520 std::vector<SpellCheckMarker>(), 519 std::vector<SpellCheckMarker>(),
521 &results); 520 &results);
522 feedback_->OnReceiveDocumentMarkers(kRendererProcessId, 521 feedback_->OnReceiveDocumentMarkers(kRendererProcessId,
523 std::vector<uint32>()); 522 std::vector<uint32>());
524 EXPECT_FALSE(IsUploadingData()); 523 EXPECT_FALSE(IsUploadingData());
525 } 524 }
526 525
527 } // namespace spellcheck 526 } // namespace spellcheck
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_manager_unittest.cc ('k') | chrome/browser/sync/sync_global_error_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698