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_uploader.h" | 5 #include "components/feedback/feedback_uploader.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
11 #include "base/prefs/testing_pref_service.h" | 12 #include "base/prefs/testing_pref_service.h" |
12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
14 #include "components/feedback/feedback_uploader_chrome.h" | 15 #include "components/feedback/feedback_uploader_chrome.h" |
15 #include "components/feedback/feedback_uploader_factory.h" | 16 #include "components/feedback/feedback_uploader_factory.h" |
16 #include "components/user_prefs/user_prefs.h" | 17 #include "components/user_prefs/user_prefs.h" |
17 #include "content/public/test/test_browser_context.h" | 18 #include "content/public/test/test_browser_context.h" |
18 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 const char kReportOne[] = "one"; | 25 const char kReportOne[] = "one"; |
25 const char kReportTwo[] = "two"; | 26 const char kReportTwo[] = "two"; |
26 const char kReportThree[] = "three"; | 27 const char kReportThree[] = "three"; |
27 const char kReportFour[] = "four"; | 28 const char kReportFour[] = "four"; |
28 const char kReportFive[] = "five"; | 29 const char kReportFive[] = "five"; |
29 | 30 |
30 const base::TimeDelta kRetryDelayForTest = | 31 const base::TimeDelta kRetryDelayForTest = |
31 base::TimeDelta::FromMilliseconds(100); | 32 base::TimeDelta::FromMilliseconds(100); |
32 | 33 |
33 KeyedService* CreateFeedbackUploaderService(content::BrowserContext* context) { | 34 scoped_ptr<KeyedService> CreateFeedbackUploaderService( |
34 return new feedback::FeedbackUploaderChrome(context); | 35 content::BrowserContext* context) { |
| 36 return make_scoped_ptr(new feedback::FeedbackUploaderChrome(context)); |
35 } | 37 } |
36 | 38 |
37 } // namespace | 39 } // namespace |
38 | 40 |
39 namespace feedback { | 41 namespace feedback { |
40 | 42 |
41 class FeedbackUploaderTest : public testing::Test { | 43 class FeedbackUploaderTest : public testing::Test { |
42 protected: | 44 protected: |
43 FeedbackUploaderTest() | 45 FeedbackUploaderTest() |
44 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 46 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 157 |
156 EXPECT_EQ(dispatched_reports_.size(), 5u); | 158 EXPECT_EQ(dispatched_reports_.size(), 5u); |
157 EXPECT_EQ(dispatched_reports_[kReportOne], 1u); | 159 EXPECT_EQ(dispatched_reports_[kReportOne], 1u); |
158 EXPECT_EQ(dispatched_reports_[kReportTwo], 2u); | 160 EXPECT_EQ(dispatched_reports_[kReportTwo], 2u); |
159 EXPECT_EQ(dispatched_reports_[kReportThree], 2u); | 161 EXPECT_EQ(dispatched_reports_[kReportThree], 2u); |
160 EXPECT_EQ(dispatched_reports_[kReportFour], 1u); | 162 EXPECT_EQ(dispatched_reports_[kReportFour], 1u); |
161 EXPECT_EQ(dispatched_reports_[kReportFive], 1u); | 163 EXPECT_EQ(dispatched_reports_[kReportFive], 1u); |
162 } | 164 } |
163 | 165 |
164 } // namespace feedback | 166 } // namespace feedback |
OLD | NEW |