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

Side by Side Diff: chrome/browser/chromeos/policy/status_uploader_unittest.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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/chromeos/policy/status_uploader.h" 5 #include "chrome/browser/chromeos/policy/status_uploader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
10 #include "base/time/time.h" 11 #include "base/time/time.h"
11 #include "chrome/browser/chromeos/policy/device_local_account.h" 12 #include "chrome/browser/chromeos/policy/device_local_account.h"
12 #include "chrome/browser/chromeos/policy/device_status_collector.h" 13 #include "chrome/browser/chromeos/policy/device_status_collector.h"
13 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h" 14 #include "chrome/browser/chromeos/settings/scoped_cros_settings_test_helper.h"
14 #include "chromeos/settings/cros_settings_names.h" 15 #include "chromeos/settings/cros_settings_names.h"
15 #include "components/policy/core/common/cloud/cloud_policy_client.h" 16 #include "components/policy/core/common/cloud/cloud_policy_client.h"
16 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h" 17 #include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
17 #include "components/policy/core/common/cloud/mock_device_management_service.h" 18 #include "components/policy/core/common/cloud/mock_device_management_service.h"
18 #include "components/prefs/testing_pref_service.h" 19 #include "components/prefs/testing_pref_service.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 policy::DeviceStatusCollector::LocationUpdateRequester(), 56 policy::DeviceStatusCollector::LocationUpdateRequester(),
56 policy::DeviceStatusCollector::VolumeInfoFetcher(), 57 policy::DeviceStatusCollector::VolumeInfoFetcher(),
57 policy::DeviceStatusCollector::CPUStatisticsFetcher(), 58 policy::DeviceStatusCollector::CPUStatisticsFetcher(),
58 policy::DeviceStatusCollector::CPUTempFetcher()) {} 59 policy::DeviceStatusCollector::CPUTempFetcher()) {}
59 60
60 MOCK_METHOD1(GetDeviceStatus, bool(em::DeviceStatusReportRequest*)); 61 MOCK_METHOD1(GetDeviceStatus, bool(em::DeviceStatusReportRequest*));
61 MOCK_METHOD1(GetDeviceSessionStatus, bool(em::SessionStatusReportRequest*)); 62 MOCK_METHOD1(GetDeviceSessionStatus, bool(em::SessionStatusReportRequest*));
62 63
63 // Explicit mock implementation declared here, since gmock::Invoke can't 64 // Explicit mock implementation declared here, since gmock::Invoke can't
64 // handle returning non-moveable types like scoped_ptr. 65 // handle returning non-moveable types like scoped_ptr.
65 scoped_ptr<policy::DeviceLocalAccount> GetAutoLaunchedKioskSessionInfo() 66 std::unique_ptr<policy::DeviceLocalAccount> GetAutoLaunchedKioskSessionInfo()
66 override { 67 override {
67 return make_scoped_ptr(new policy::DeviceLocalAccount( 68 return base::WrapUnique(new policy::DeviceLocalAccount(
68 policy::DeviceLocalAccount::TYPE_KIOSK_APP, "account_id", "app_id", 69 policy::DeviceLocalAccount::TYPE_KIOSK_APP, "account_id", "app_id",
69 "update_url")); 70 "update_url"));
70 } 71 }
71 }; 72 };
72 73
73 } // namespace 74 } // namespace
74 75
75 namespace policy { 76 namespace policy {
76 class StatusUploaderTest : public testing::Test { 77 class StatusUploaderTest : public testing::Test {
77 public: 78 public:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 base::Time now = base::Time::NowFromSystemTime(); 124 base::Time now = base::Time::NowFromSystemTime();
124 base::Time next_task = now + task_runner_->NextPendingTaskDelay(); 125 base::Time next_task = now + task_runner_->NextPendingTaskDelay();
125 126
126 EXPECT_LE(next_task, now + expected_delay); 127 EXPECT_LE(next_task, now + expected_delay);
127 EXPECT_GE(next_task, uploader.last_upload() + expected_delay); 128 EXPECT_GE(next_task, uploader.last_upload() + expected_delay);
128 } 129 }
129 130
130 content::TestBrowserThreadBundle thread_bundle_; 131 content::TestBrowserThreadBundle thread_bundle_;
131 scoped_refptr<base::TestSimpleTaskRunner> task_runner_; 132 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
132 chromeos::ScopedCrosSettingsTestHelper settings_helper_; 133 chromeos::ScopedCrosSettingsTestHelper settings_helper_;
133 scoped_ptr<MockDeviceStatusCollector> collector_; 134 std::unique_ptr<MockDeviceStatusCollector> collector_;
134 ui::UserActivityDetector detector_; 135 ui::UserActivityDetector detector_;
135 MockCloudPolicyClient client_; 136 MockCloudPolicyClient client_;
136 MockDeviceManagementService device_management_service_; 137 MockDeviceManagementService device_management_service_;
137 TestingPrefServiceSimple prefs_; 138 TestingPrefServiceSimple prefs_;
138 }; 139 };
139 140
140 TEST_F(StatusUploaderTest, BasicTest) { 141 TEST_F(StatusUploaderTest, BasicTest) {
141 EXPECT_TRUE(task_runner_->GetPendingTasks().empty()); 142 EXPECT_TRUE(task_runner_->GetPendingTasks().empty());
142 StatusUploader uploader(&client_, std::move(collector_), task_runner_); 143 StatusUploader uploader(&client_, std::move(collector_), task_runner_);
143 EXPECT_EQ(1U, task_runner_->GetPendingTasks().size()); 144 EXPECT_EQ(1U, task_runner_->GetPendingTasks().size());
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 // Now mock video capture, and no session data should be allowed. 255 // Now mock video capture, and no session data should be allowed.
255 MediaCaptureDevicesDispatcher::GetInstance()->OnMediaRequestStateChanged( 256 MediaCaptureDevicesDispatcher::GetInstance()->OnMediaRequestStateChanged(
256 0, 0, 0, GURL("http://www.google.com"), 257 0, 0, 0, GURL("http://www.google.com"),
257 content::MEDIA_DEVICE_VIDEO_CAPTURE, 258 content::MEDIA_DEVICE_VIDEO_CAPTURE,
258 content::MEDIA_REQUEST_STATE_OPENING); 259 content::MEDIA_REQUEST_STATE_OPENING);
259 base::RunLoop().RunUntilIdle(); 260 base::RunLoop().RunUntilIdle();
260 EXPECT_FALSE(uploader.IsSessionDataUploadAllowed()); 261 EXPECT_FALSE(uploader.IsSessionDataUploadAllowed());
261 } 262 }
262 263
263 } // namespace policy 264 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/policy/status_uploader.cc ('k') | chrome/browser/chromeos/policy/system_log_uploader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698