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

Unified Diff: chrome/browser/chromeos/policy/device_status_collector_browsertest.cc

Issue 2869673003: Fix system active time reporting for app kiosks (Closed)
Patch Set: Removed a duplicate test Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/policy/device_status_collector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/policy/device_status_collector_browsertest.cc
diff --git a/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc b/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc
index 276c6365e2ed8467994c2a7543bbcc477ca2a091..0afa872e4cb39977c8fc2e654b4bf6d938213172 100644
--- a/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc
+++ b/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc
@@ -47,6 +47,7 @@
#include "chromeos/dbus/shill_service_client.h"
#include "chromeos/disks/disk_mount_manager.h"
#include "chromeos/disks/mock_disk_mount_manager.h"
+#include "chromeos/login/login_state.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
@@ -344,6 +345,7 @@ class DeviceStatusCollectorTest : public testing::Test {
base::WrapUnique<chromeos::UpdateEngineClient>(update_engine_client_));
chromeos::CrasAudioHandler::InitializeForTesting();
+ chromeos::LoginState::Initialize();
}
void AddMountPoint(const std::string& mount_point) {
@@ -355,6 +357,7 @@ class DeviceStatusCollectorTest : public testing::Test {
}
~DeviceStatusCollectorTest() override {
+ chromeos::LoginState::Shutdown();
chromeos::CrasAudioHandler::Shutdown();
chromeos::KioskAppManager::Shutdown();
TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr);
@@ -580,35 +583,48 @@ TEST_F(DeviceStatusCollectorTest, MixedStates) {
GetActiveMilliseconds(device_status_));
}
-TEST_F(DeviceStatusCollectorTest, StateKeptInPref) {
+// For kiosks report total uptime instead of only active periods.
+TEST_F(DeviceStatusCollectorTest, MixedStatesForKiosk) {
ui::IdleState test_states[] = {
ui::IDLE_STATE_ACTIVE,
ui::IDLE_STATE_IDLE,
ui::IDLE_STATE_ACTIVE,
ui::IDLE_STATE_ACTIVE,
ui::IDLE_STATE_IDLE,
- ui::IDLE_STATE_IDLE
+ ui::IDLE_STATE_IDLE,
};
+ chromeos::LoginState::Get()->SetLoggedInState(
+ chromeos::LoginState::LOGGED_IN_ACTIVE,
+ chromeos::LoginState::LOGGED_IN_USER_KIOSK_APP);
settings_helper_.SetBoolean(chromeos::kReportDeviceActivityTimes, true);
status_collector_->Simulate(test_states,
sizeof(test_states) / sizeof(ui::IdleState));
+ GetStatus();
+ EXPECT_EQ(6 * ActivePeriodMilliseconds(),
+ GetActiveMilliseconds(device_status_));
+}
- // Process the list a second time after restarting the collector. It should be
- // able to count the active periods found by the original collector, because
- // the results are stored in a pref.
- RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo),
- base::Bind(&GetEmptyCPUStatistics),
- base::Bind(&GetEmptyCPUTempInfo),
- base::Bind(&GetEmptyAndroidStatus));
+// For Arc kiosks report total uptime instead of only active periods.
+TEST_F(DeviceStatusCollectorTest, MixedStatesForArcKiosk) {
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_IDLE,
+ };
+ chromeos::LoginState::Get()->SetLoggedInState(
+ chromeos::LoginState::LOGGED_IN_ACTIVE,
+ chromeos::LoginState::LOGGED_IN_USER_ARC_KIOSK_APP);
+ settings_helper_.SetBoolean(chromeos::kReportDeviceActivityTimes, true);
status_collector_->Simulate(test_states,
sizeof(test_states) / sizeof(ui::IdleState));
-
GetStatus();
- EXPECT_EQ(6 * ActivePeriodMilliseconds(),
+ EXPECT_EQ(5 * ActivePeriodMilliseconds(),
GetActiveMilliseconds(device_status_));
}
-TEST_F(DeviceStatusCollectorTest, Times) {
Ivan Šandrk 2017/05/09 14:22:06 I removed this test as it's the same as MixedState
+TEST_F(DeviceStatusCollectorTest, StateKeptInPref) {
ui::IdleState test_states[] = {
ui::IDLE_STATE_ACTIVE,
ui::IDLE_STATE_IDLE,
@@ -620,8 +636,19 @@ TEST_F(DeviceStatusCollectorTest, Times) {
settings_helper_.SetBoolean(chromeos::kReportDeviceActivityTimes, true);
status_collector_->Simulate(test_states,
sizeof(test_states) / sizeof(ui::IdleState));
+
+ // Process the list a second time after restarting the collector. It should be
+ // able to count the active periods found by the original collector, because
+ // the results are stored in a pref.
+ RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo),
+ base::Bind(&GetEmptyCPUStatistics),
+ base::Bind(&GetEmptyCPUTempInfo),
+ base::Bind(&GetEmptyAndroidStatus));
+ status_collector_->Simulate(test_states,
+ sizeof(test_states) / sizeof(ui::IdleState));
+
GetStatus();
- EXPECT_EQ(3 * ActivePeriodMilliseconds(),
+ EXPECT_EQ(6 * ActivePeriodMilliseconds(),
GetActiveMilliseconds(device_status_));
}
« no previous file with comments | « chrome/browser/chromeos/policy/device_status_collector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698