| OLD | NEW |
| 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/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "components/feedback/feedback_uploader.h" | 13 #include "components/feedback/feedback_uploader.h" |
| 14 #include "components/feedback/feedback_uploader_factory.h" | 14 #include "components/feedback/feedback_uploader_factory.h" |
| 15 #include "components/keyed_service/core/keyed_service.h" | 15 #include "components/keyed_service/core/keyed_service.h" |
| 16 #include "components/prefs/testing_pref_service.h" | 16 #include "components/prefs/testing_pref_service.h" |
| 17 #include "components/user_prefs/user_prefs.h" | 17 #include "components/user_prefs/user_prefs.h" |
| 18 #include "content/public/test/test_browser_context.h" | 18 #include "content/public/test/test_browser_context.h" |
| 19 #include "content/public/test/test_browser_thread.h" | |
| 20 #include "content/public/test/test_browser_thread_bundle.h" | 19 #include "content/public/test/test_browser_thread_bundle.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 22 |
| 24 namespace { | 23 namespace { |
| 25 | 24 |
| 26 const char kHistograms[] = ""; | 25 const char kHistograms[] = ""; |
| 27 const char kImageData[] = ""; | 26 const char kImageData[] = ""; |
| 28 const char kFileData[] = ""; | 27 const char kFileData[] = ""; |
| 29 | 28 |
| 30 using content::BrowserThread; | |
| 31 | |
| 32 class MockUploader : public feedback::FeedbackUploader, public KeyedService { | 29 class MockUploader : public feedback::FeedbackUploader, public KeyedService { |
| 33 public: | 30 public: |
| 34 MockUploader(content::BrowserContext* context) | 31 MockUploader(content::BrowserContext* context) |
| 35 : FeedbackUploader(context ? context->GetPath() : base::FilePath(), | 32 : FeedbackUploader(context ? context->GetPath() : base::FilePath()) {} |
| 36 BrowserThread::GetBlockingPool()) {} | |
| 37 | 33 |
| 38 MOCK_METHOD1(DispatchReport, void(const std::string&)); | 34 MOCK_METHOD1(DispatchReport, void(const std::string&)); |
| 39 }; | 35 }; |
| 40 | 36 |
| 41 std::unique_ptr<KeyedService> CreateFeedbackUploaderService( | 37 std::unique_ptr<KeyedService> CreateFeedbackUploaderService( |
| 42 content::BrowserContext* context) { | 38 content::BrowserContext* context) { |
| 43 std::unique_ptr<MockUploader> uploader(new MockUploader(context)); | 39 std::unique_ptr<MockUploader> uploader(new MockUploader(context)); |
| 44 EXPECT_CALL(*uploader, DispatchReport(testing::_)).Times(1); | 40 EXPECT_CALL(*uploader, DispatchReport(testing::_)).Times(1); |
| 45 return std::move(uploader); | 41 return std::move(uploader); |
| 46 } | 42 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 TEST_F(FeedbackDataTest, ReportSending) { | 96 TEST_F(FeedbackDataTest, ReportSending) { |
| 101 data_->SetAndCompressHistograms(MakeScoped(kHistograms)); | 97 data_->SetAndCompressHistograms(MakeScoped(kHistograms)); |
| 102 data_->set_image(MakeScoped(kImageData)); | 98 data_->set_image(MakeScoped(kImageData)); |
| 103 data_->AttachAndCompressFileData(MakeScoped(kFileData)); | 99 data_->AttachAndCompressFileData(MakeScoped(kFileData)); |
| 104 Send(); | 100 Send(); |
| 105 RunMessageLoop(); | 101 RunMessageLoop(); |
| 106 EXPECT_TRUE(data_->IsDataComplete()); | 102 EXPECT_TRUE(data_->IsDataComplete()); |
| 107 } | 103 } |
| 108 | 104 |
| 109 } // namespace feedback | 105 } // namespace feedback |
| OLD | NEW |