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

Side by Side Diff: components/feedback/feedback_data_unittest.cc

Issue 2799253002: Switch from TestBrowserThread to TestBrowserThreadBundle in components. (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « no previous file | components/feedback/feedback_uploader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/feedback/feedback_data.h" 5 #include "components/feedback/feedback_data.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 12 #include "base/run_loop.h"
14 #include "components/feedback/feedback_uploader.h" 13 #include "components/feedback/feedback_uploader.h"
15 #include "components/feedback/feedback_uploader_factory.h" 14 #include "components/feedback/feedback_uploader_factory.h"
16 #include "components/keyed_service/core/keyed_service.h" 15 #include "components/keyed_service/core/keyed_service.h"
17 #include "components/prefs/testing_pref_service.h" 16 #include "components/prefs/testing_pref_service.h"
18 #include "components/user_prefs/user_prefs.h" 17 #include "components/user_prefs/user_prefs.h"
19 #include "content/public/test/test_browser_context.h" 18 #include "content/public/test/test_browser_context.h"
20 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
20 #include "content/public/test/test_browser_thread_bundle.h"
21 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 namespace { 24 namespace {
25 25
26 const char kHistograms[] = ""; 26 const char kHistograms[] = "";
27 const char kImageData[] = ""; 27 const char kImageData[] = "";
28 const char kFileData[] = ""; 28 const char kFileData[] = "";
29 29
30 using content::BrowserThread; 30 using content::BrowserThread;
(...skipping 20 matching lines...) Expand all
51 51
52 } // namespace 52 } // namespace
53 53
54 namespace feedback { 54 namespace feedback {
55 55
56 class FeedbackDataTest : public testing::Test { 56 class FeedbackDataTest : public testing::Test {
57 protected: 57 protected:
58 FeedbackDataTest() 58 FeedbackDataTest()
59 : context_(new content::TestBrowserContext()), 59 : context_(new content::TestBrowserContext()),
60 prefs_(new TestingPrefServiceSimple()), 60 prefs_(new TestingPrefServiceSimple()),
61 data_(new FeedbackData()), 61 data_(new FeedbackData()) {
62 ui_thread_(content::BrowserThread::UI, &message_loop_) {
63 user_prefs::UserPrefs::Set(context_.get(), prefs_.get()); 62 user_prefs::UserPrefs::Set(context_.get(), prefs_.get());
64 data_->set_context(context_.get()); 63 data_->set_context(context_.get());
65 data_->set_send_report_callback(base::Bind( 64 data_->set_send_report_callback(base::Bind(
66 &FeedbackDataTest::set_send_report_callback, base::Unretained(this))); 65 &FeedbackDataTest::set_send_report_callback, base::Unretained(this)));
67 66
68 FeedbackUploaderFactory::GetInstance()->SetTestingFactory( 67 FeedbackUploaderFactory::GetInstance()->SetTestingFactory(
69 context_.get(), &CreateFeedbackUploaderService); 68 context_.get(), &CreateFeedbackUploaderService);
70 } 69 }
71 70
72 void Send() { 71 void Send() {
(...skipping 15 matching lines...) Expand all
88 87
89 void set_send_report_callback(scoped_refptr<FeedbackData> data) { 88 void set_send_report_callback(scoped_refptr<FeedbackData> data) {
90 quit_closure_.Run(); 89 quit_closure_.Run();
91 } 90 }
92 91
93 base::Closure quit_closure_; 92 base::Closure quit_closure_;
94 std::unique_ptr<base::RunLoop> run_loop_; 93 std::unique_ptr<base::RunLoop> run_loop_;
95 std::unique_ptr<content::TestBrowserContext> context_; 94 std::unique_ptr<content::TestBrowserContext> context_;
96 std::unique_ptr<PrefService> prefs_; 95 std::unique_ptr<PrefService> prefs_;
97 scoped_refptr<FeedbackData> data_; 96 scoped_refptr<FeedbackData> data_;
98 base::MessageLoop message_loop_; 97 content::TestBrowserThreadBundle test_browser_thread_bundle_;
99 content::TestBrowserThread ui_thread_;
100 }; 98 };
101 99
102 TEST_F(FeedbackDataTest, ReportSending) { 100 TEST_F(FeedbackDataTest, ReportSending) {
103 data_->SetAndCompressHistograms(MakeScoped(kHistograms)); 101 data_->SetAndCompressHistograms(MakeScoped(kHistograms));
104 data_->set_image(MakeScoped(kImageData)); 102 data_->set_image(MakeScoped(kImageData));
105 data_->AttachAndCompressFileData(MakeScoped(kFileData)); 103 data_->AttachAndCompressFileData(MakeScoped(kFileData));
106 Send(); 104 Send();
107 RunMessageLoop(); 105 RunMessageLoop();
108 EXPECT_TRUE(data_->IsDataComplete()); 106 EXPECT_TRUE(data_->IsDataComplete());
109 } 107 }
110 108
111 } // namespace feedback 109 } // namespace feedback
OLDNEW
« no previous file with comments | « no previous file | components/feedback/feedback_uploader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698