| OLD | NEW |
| 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 Loading... |
| 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 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 EXPECT_EQ(dispatched_reports_[0], kReportOne); | 128 EXPECT_EQ(dispatched_reports_[0], kReportOne); |
| 129 EXPECT_EQ(dispatched_reports_[1], kReportTwo); | 129 EXPECT_EQ(dispatched_reports_[1], kReportTwo); |
| 130 EXPECT_EQ(dispatched_reports_[2], kReportThree); | 130 EXPECT_EQ(dispatched_reports_[2], kReportThree); |
| 131 EXPECT_EQ(dispatched_reports_[3], kReportFour); | 131 EXPECT_EQ(dispatched_reports_[3], kReportFour); |
| 132 EXPECT_EQ(dispatched_reports_[4], kReportFive); | 132 EXPECT_EQ(dispatched_reports_[4], kReportFive); |
| 133 EXPECT_EQ(dispatched_reports_[5], kReportThree); | 133 EXPECT_EQ(dispatched_reports_[5], kReportThree); |
| 134 EXPECT_EQ(dispatched_reports_[6], kReportTwo); | 134 EXPECT_EQ(dispatched_reports_[6], kReportTwo); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace feedback | 137 } // namespace feedback |
| OLD | NEW |