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

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

Issue 1547093002: Switch to standard integer types in chrome/browser/chromeos/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/device_status_collector.h" 5 #include "chrome/browser/chromeos/policy/device_status_collector.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include <string> 10 #include <string>
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/bind.h" 13 #include "base/bind.h"
11 #include "base/environment.h" 14 #include "base/environment.h"
12 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
15 #include "base/prefs/pref_service.h" 19 #include "base/prefs/pref_service.h"
16 #include "base/prefs/testing_pref_service.h" 20 #include "base/prefs/testing_pref_service.h"
17 #include "base/run_loop.h" 21 #include "base/run_loop.h"
18 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
19 #include "base/threading/sequenced_worker_pool.h" 23 #include "base/threading/sequenced_worker_pool.h"
20 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 24 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
21 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 25 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
22 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h" 26 #include "chrome/browser/chromeos/ownership/fake_owner_settings_service.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 using ::testing::Return; 58 using ::testing::Return;
55 using ::testing::ReturnRef; 59 using ::testing::ReturnRef;
56 using base::Time; 60 using base::Time;
57 using base::TimeDelta; 61 using base::TimeDelta;
58 using chromeos::disks::DiskMountManager; 62 using chromeos::disks::DiskMountManager;
59 63
60 namespace em = enterprise_management; 64 namespace em = enterprise_management;
61 65
62 namespace { 66 namespace {
63 67
64 const int64 kMillisecondsPerDay = Time::kMicrosecondsPerDay / 1000; 68 const int64_t kMillisecondsPerDay = Time::kMicrosecondsPerDay / 1000;
65 const char kKioskAccountId[] = "kiosk_user@localhost"; 69 const char kKioskAccountId[] = "kiosk_user@localhost";
66 const char kKioskAppId[] = "kiosk_app_id"; 70 const char kKioskAppId[] = "kiosk_app_id";
67 const char kExternalMountPoint[] = "/a/b/c"; 71 const char kExternalMountPoint[] = "/a/b/c";
68 const char kPublicAccountId[] = "public_user@localhost"; 72 const char kPublicAccountId[] = "public_user@localhost";
69 73
70 scoped_ptr<content::Geoposition> mock_position_to_return_next; 74 scoped_ptr<content::Geoposition> mock_position_to_return_next;
71 75
72 void SetMockPositionToReturnNext(const content::Geoposition &position) { 76 void SetMockPositionToReturnNext(const content::Geoposition &position) {
73 mock_position_to_return_next.reset(new content::Geoposition(position)); 77 mock_position_to_return_next.reset(new content::Geoposition(position));
74 } 78 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 Time baseline_time_; 175 Time baseline_time_;
172 176
173 // The number of simulated periods since the baseline time. 177 // The number of simulated periods since the baseline time.
174 int baseline_offset_periods_; 178 int baseline_offset_periods_;
175 179
176 scoped_ptr<policy::DeviceLocalAccount> kiosk_account_; 180 scoped_ptr<policy::DeviceLocalAccount> kiosk_account_;
177 }; 181 };
178 182
179 // Return the total number of active milliseconds contained in a device 183 // Return the total number of active milliseconds contained in a device
180 // status report. 184 // status report.
181 int64 GetActiveMilliseconds(em::DeviceStatusReportRequest& status) { 185 int64_t GetActiveMilliseconds(em::DeviceStatusReportRequest& status) {
182 int64 active_milliseconds = 0; 186 int64_t active_milliseconds = 0;
183 for (int i = 0; i < status.active_period_size(); i++) { 187 for (int i = 0; i < status.active_period_size(); i++) {
184 active_milliseconds += status.active_period(i).active_duration(); 188 active_milliseconds += status.active_period(i).active_duration();
185 } 189 }
186 return active_milliseconds; 190 return active_milliseconds;
187 } 191 }
188 192
189 // Mock CPUStatisticsFetcher used to return an empty set of statistics. 193 // Mock CPUStatisticsFetcher used to return an empty set of statistics.
190 std::string GetEmptyCPUStatistics() { 194 std::string GetEmptyCPUStatistics() {
191 return std::string(); 195 return std::string();
192 } 196 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 accounts.push_back(account); 383 accounts.push_back(account);
380 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts); 384 SetDeviceLocalAccounts(owner_settings_service_.get(), accounts);
381 user_manager_->CreateKioskAppUser( 385 user_manager_->CreateKioskAppUser(
382 AccountId::FromUserEmail(account.user_id)); 386 AccountId::FromUserEmail(account.user_id));
383 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly( 387 EXPECT_CALL(*user_manager_, IsLoggedInAsKioskApp()).WillRepeatedly(
384 Return(true)); 388 Return(true));
385 } 389 }
386 390
387 protected: 391 protected:
388 // Convenience method. 392 // Convenience method.
389 int64 ActivePeriodMilliseconds() { 393 int64_t ActivePeriodMilliseconds() {
390 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000; 394 return policy::DeviceStatusCollector::kIdlePollIntervalSeconds * 1000;
391 } 395 }
392 396
393 // Since this is a unit test running in browser_tests we must do additional 397 // Since this is a unit test running in browser_tests we must do additional
394 // unit test setup and make a TestingBrowserProcess. Must be first member. 398 // unit test setup and make a TestingBrowserProcess. Must be first member.
395 TestingBrowserProcessInitializer initializer_; 399 TestingBrowserProcessInitializer initializer_;
396 base::MessageLoopForUI message_loop_; 400 base::MessageLoopForUI message_loop_;
397 content::TestBrowserThread ui_thread_; 401 content::TestBrowserThread ui_thread_;
398 content::TestBrowserThread file_thread_; 402 content::TestBrowserThread file_thread_;
399 content::TestBrowserThread io_thread_; 403 content::TestBrowserThread io_thread_;
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 AccountId::FromUserEmail(kPublicAccountId)); 1311 AccountId::FromUserEmail(kPublicAccountId));
1308 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount()) 1312 EXPECT_CALL(*user_manager_, IsLoggedInAsPublicAccount())
1309 .WillRepeatedly(Return(true)); 1313 .WillRepeatedly(Return(true));
1310 1314
1311 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true); 1315 settings_helper_.SetBoolean(chromeos::kReportDeviceNetworkInterfaces, true);
1312 GetStatus(); 1316 GetStatus();
1313 VerifyNetworkReporting(); 1317 VerifyNetworkReporting();
1314 } 1318 }
1315 1319
1316 } // namespace policy 1320 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698