OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/app_mode/kiosk_app_update_service.h" |
| 6 |
5 #include <string> | 7 #include <string> |
6 | 8 |
7 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
14 #include "base/path_service.h" | 16 #include "base/path_service.h" |
15 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
16 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
17 #include "base/test/scoped_path_override.h" | 19 #include "base/test/scoped_path_override.h" |
18 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
19 #include "base/time/time.h" | 21 #include "base/time/time.h" |
20 #include "chrome/browser/apps/app_browsertest_util.h" | 22 #include "chrome/browser/apps/app_browsertest_util.h" |
21 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/browser_process_platform_part.h" | 24 #include "chrome/browser/browser_process_platform_part.h" |
23 #include "chrome/browser/chromeos/app_mode/kiosk_app_update_service.h" | |
24 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" | 25 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" |
25 #include "chrome/browser/extensions/extension_test_message_listener.h" | 26 #include "chrome/browser/extensions/extension_test_message_listener.h" |
26 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
29 #include "chromeos/chromeos_paths.h" | 30 #include "chromeos/chromeos_paths.h" |
30 #include "chromeos/dbus/update_engine_client.h" | 31 #include "chromeos/dbus/update_engine_client.h" |
31 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/test/test_utils.h" | 33 #include "content/public/test/test_utils.h" |
33 #include "extensions/common/extension.h" | 34 #include "extensions/common/extension.h" |
(...skipping 27 matching lines...) Expand all Loading... |
61 test_data_dir_.AppendASCII("api_test/runtime/on_restart_required")); | 62 test_data_dir_.AppendASCII("api_test/runtime/on_restart_required")); |
62 | 63 |
63 // Fake app mode command line. | 64 // Fake app mode command line. |
64 CommandLine* command = CommandLine::ForCurrentProcess(); | 65 CommandLine* command = CommandLine::ForCurrentProcess(); |
65 command->AppendSwitch(switches::kForceAppMode); | 66 command->AppendSwitch(switches::kForceAppMode); |
66 command->AppendSwitchASCII(switches::kAppId, app_->id()); | 67 command->AppendSwitchASCII(switches::kAppId, app_->id()); |
67 | 68 |
68 update_service_ = KioskAppUpdateServiceFactory::GetForProfile(profile()); | 69 update_service_ = KioskAppUpdateServiceFactory::GetForProfile(profile()); |
69 update_service_->set_app_id(app_->id()); | 70 update_service_->set_app_id(app_->id()); |
70 | 71 |
71 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 72 content::RunAllBlockingPoolTasksUntilIdle(); |
72 content::RunAllPendingInMessageLoop(); | |
73 } | 73 } |
74 | 74 |
75 void FireAppUpdateAvailable() { | 75 void FireAppUpdateAvailable() { |
76 update_service_->OnAppUpdateAvailable(app_); | 76 update_service_->OnAppUpdateAvailable(app_); |
77 } | 77 } |
78 | 78 |
79 void FireUpdatedNeedReboot() { | 79 void FireUpdatedNeedReboot() { |
80 UpdateEngineClient::Status status; | 80 UpdateEngineClient::Status status; |
81 status.status = UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT; | 81 status.status = UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT; |
82 g_browser_process->platform_part()->automatic_reboot_manager()-> | 82 g_browser_process->platform_part()->automatic_reboot_manager()-> |
(...skipping 26 matching lines...) Expand all Loading... |
109 | 109 |
110 IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, Periodic) { | 110 IN_PROC_BROWSER_TEST_F(KioskAppUpdateServiceTest, Periodic) { |
111 g_browser_process->local_state()->SetInteger( | 111 g_browser_process->local_state()->SetInteger( |
112 prefs::kUptimeLimit, base::TimeDelta::FromMinutes(30).InSeconds()); | 112 prefs::kUptimeLimit, base::TimeDelta::FromMinutes(30).InSeconds()); |
113 | 113 |
114 ExtensionTestMessageListener listener("periodic", false); | 114 ExtensionTestMessageListener listener("periodic", false); |
115 listener.WaitUntilSatisfied(); | 115 listener.WaitUntilSatisfied(); |
116 } | 116 } |
117 | 117 |
118 } // namespace chromeos | 118 } // namespace chromeos |
OLD | NEW |