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

Side by Side Diff: trunk/src/chrome/browser/feedback/feedback_uploader_unittest.cc

Issue 149993002: Revert 247772 "Cache feedback reports to disk in case of send fa..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/browser/feedback/feedback_uploader.h" 5 #include "chrome/browser/feedback/feedback_uploader.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/feedback/feedback_uploader_factory.h" 10 #include "chrome/browser/feedback/feedback_uploader_factory.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 base::Unretained(this)), 47 base::Unretained(this)),
48 kRetryDelayForTest); 48 kRetryDelayForTest);
49 } 49 }
50 50
51 virtual ~FeedbackUploaderTest() { 51 virtual ~FeedbackUploaderTest() {
52 FeedbackUploaderFactory::GetInstance()->SetTestingFactory( 52 FeedbackUploaderFactory::GetInstance()->SetTestingFactory(
53 profile_.get(), NULL); 53 profile_.get(), NULL);
54 } 54 }
55 55
56 void QueueReport(const std::string& data) { 56 void QueueReport(const std::string& data) {
57 uploader_->QueueReport(data); 57 uploader_->QueueReport(make_scoped_ptr(new std::string(data)));
58 } 58 }
59 59
60 void ReportFailure(const std::string& data) { 60 void ReportFailure(const std::string& data) {
61 uploader_->RetryReport(data); 61 uploader_->RetryReport(make_scoped_ptr(new std::string(data)));
62 } 62 }
63 63
64 void MockDispatchReport(const std::string& report_data) { 64 void MockDispatchReport(scoped_ptr<std::string> report_data) {
65 dispatched_reports_.push_back(report_data); 65 dispatched_reports_.push_back(*report_data.get());
66 66
67 // Dispatch will always update the timer, whether successful or not, 67 // Dispatch will always update the timer, whether successful or not,
68 // simulate the same behavior. 68 // simulate the same behavior.
69 uploader_->UpdateUploadTimer(); 69 uploader_->UpdateUploadTimer();
70 70
71 if (dispatched_reports_.size() >= expected_reports_) { 71 if (dispatched_reports_.size() >= expected_reports_) {
72 if (run_loop_.get()) 72 if (run_loop_.get())
73 run_loop_->Quit(); 73 run_loop_->Quit();
74 } 74 }
75 } 75 }
76 76
77 void RunMessageLoop() { 77 void RunMessageLoop() {
78 run_loop_.reset(new base::RunLoop()); 78 run_loop_.reset(new base::RunLoop());
79 run_loop_->Run(); 79 run_loop_->Run();
80 } 80 }
81 81
82 base::MessageLoop message_loop_; 82 base::MessageLoop message_loop_;
83 scoped_ptr<base::RunLoop> run_loop_; 83 scoped_ptr<base::RunLoop> run_loop_;
84 content::TestBrowserThread ui_thread_; 84 content::TestBrowserThread ui_thread_;
85 scoped_ptr<TestingProfile> profile_; 85 scoped_ptr<TestingProfile> profile_;
86 86
87 FeedbackUploader* uploader_; 87 FeedbackUploader* uploader_;
88 88
89 std::vector<std::string> dispatched_reports_; 89 std::vector<std::string> dispatched_reports_;
90 size_t expected_reports_; 90 size_t expected_reports_;
91 }; 91 };
92 92
93 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 93 TEST_F(FeedbackUploaderTest, QueueMultiple) {
94 #define MAYBE_QueueMultiple QueueMultiple
95 #else
96 // crbug.com/330547
97 #define MAYBE_QueueMultiple DISABLED_QueueMultiple
98 #endif
99 TEST_F(FeedbackUploaderTest, MAYBE_QueueMultiple) {
100 dispatched_reports_.clear(); 94 dispatched_reports_.clear();
101 QueueReport(kReportOne); 95 QueueReport(kReportOne);
102 QueueReport(kReportTwo); 96 QueueReport(kReportTwo);
103 QueueReport(kReportThree); 97 QueueReport(kReportThree);
104 QueueReport(kReportFour); 98 QueueReport(kReportFour);
105 99
106 EXPECT_EQ(dispatched_reports_.size(), 4u); 100 EXPECT_EQ(dispatched_reports_.size(), 4u);
107 EXPECT_EQ(dispatched_reports_[0], kReportOne); 101 EXPECT_EQ(dispatched_reports_[0], kReportOne);
108 EXPECT_EQ(dispatched_reports_[1], kReportTwo); 102 EXPECT_EQ(dispatched_reports_[1], kReportTwo);
109 EXPECT_EQ(dispatched_reports_[2], kReportThree); 103 EXPECT_EQ(dispatched_reports_[2], kReportThree);
110 EXPECT_EQ(dispatched_reports_[3], kReportFour); 104 EXPECT_EQ(dispatched_reports_[3], kReportFour);
111 } 105 }
112 106
113 #if defined(OS_LINUX) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 107 #if defined(OS_WIN)
114 #define MAYBE_QueueMultipleWithFailures QueueMultipleWithFailures
115 #else
116 // crbug.com/330547 108 // crbug.com/330547
117 #define MAYBE_QueueMultipleWithFailures DISABLED_QueueMultipleWithFailures 109 #define MAYBE_QueueMultipleWithFailures DISABLED_QueueMultipleWithFailures
110 #else
111 #define MAYBE_QueueMultipleWithFailures QueueMultipleWithFailures
118 #endif 112 #endif
119 TEST_F(FeedbackUploaderTest, MAYBE_QueueMultipleWithFailures) { 113 TEST_F(FeedbackUploaderTest, MAYBE_QueueMultipleWithFailures) {
120 dispatched_reports_.clear(); 114 dispatched_reports_.clear();
121 QueueReport(kReportOne); 115 QueueReport(kReportOne);
122 QueueReport(kReportTwo); 116 QueueReport(kReportTwo);
123 QueueReport(kReportThree); 117 QueueReport(kReportThree);
124 QueueReport(kReportFour); 118 QueueReport(kReportFour);
125 119
126 ReportFailure(kReportThree); 120 ReportFailure(kReportThree);
127 ReportFailure(kReportTwo); 121 ReportFailure(kReportTwo);
128 QueueReport(kReportFive); 122 QueueReport(kReportFive);
129 123
130 expected_reports_ = 7; 124 expected_reports_ = 7;
131 RunMessageLoop(); 125 RunMessageLoop();
132 126
133 EXPECT_EQ(dispatched_reports_.size(), 7u); 127 EXPECT_EQ(dispatched_reports_.size(), 7u);
134 EXPECT_EQ(dispatched_reports_[0], kReportOne); 128 EXPECT_EQ(dispatched_reports_[0], kReportOne);
135 EXPECT_EQ(dispatched_reports_[1], kReportTwo); 129 EXPECT_EQ(dispatched_reports_[1], kReportTwo);
136 EXPECT_EQ(dispatched_reports_[2], kReportThree); 130 EXPECT_EQ(dispatched_reports_[2], kReportThree);
137 EXPECT_EQ(dispatched_reports_[3], kReportFour); 131 EXPECT_EQ(dispatched_reports_[3], kReportFour);
138 EXPECT_EQ(dispatched_reports_[4], kReportFive); 132 EXPECT_EQ(dispatched_reports_[4], kReportFive);
139 EXPECT_EQ(dispatched_reports_[5], kReportThree); 133 EXPECT_EQ(dispatched_reports_[5], kReportThree);
140 EXPECT_EQ(dispatched_reports_[6], kReportTwo); 134 EXPECT_EQ(dispatched_reports_[6], kReportTwo);
141 } 135 }
142 136
143 } // namespace feedback 137 } // namespace feedback
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/feedback/feedback_uploader_delegate.cc ('k') | trunk/src/chrome/browser/feedback/feedback_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698