| 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_manager.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" | 13 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" |
| 14 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 15 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 14 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 16 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 15 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
| 16 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
| 18 #include "net/base/host_port_pair.h" | 20 #include "net/base/host_port_pair.h" |
| 19 #include "net/dns/mock_host_resolver.h" | 21 #include "net/dns/mock_host_resolver.h" |
| 20 | 22 |
| 21 namespace chromeos { | 23 namespace chromeos { |
| 22 | 24 |
| 23 namespace { | 25 namespace { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 apps_dict->SetString("app_1.name", "App1 Name"); | 196 apps_dict->SetString("app_1.name", "App1 Name"); |
| 195 std::string icon_path = | 197 std::string icon_path = |
| 196 base::StringPrintf("%s/red16x16.png", data_dir.value().c_str()); | 198 base::StringPrintf("%s/red16x16.png", data_dir.value().c_str()); |
| 197 apps_dict->SetString("app_1.icon", icon_path); | 199 apps_dict->SetString("app_1.icon", icon_path); |
| 198 | 200 |
| 199 PrefService* local_state = g_browser_process->local_state(); | 201 PrefService* local_state = g_browser_process->local_state(); |
| 200 DictionaryPrefUpdate dict_update(local_state, | 202 DictionaryPrefUpdate dict_update(local_state, |
| 201 KioskAppManager::kKioskDictionaryName); | 203 KioskAppManager::kKioskDictionaryName); |
| 202 dict_update->Set(KioskAppManager::kKeyApps, apps_dict.release()); | 204 dict_update->Set(KioskAppManager::kKeyApps, apps_dict.release()); |
| 203 | 205 |
| 204 // Triggers reload prefs. | 206 // Make the app appear in device settings. |
| 205 manager()->RemoveApp("dummy"); | 207 base::ListValue device_local_accounts; |
| 208 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 209 entry->SetStringWithoutPathExpansion( |
| 210 kAccountsPrefDeviceLocalAccountsKeyId, |
| 211 "app_1_id"); |
| 212 entry->SetIntegerWithoutPathExpansion( |
| 213 kAccountsPrefDeviceLocalAccountsKeyType, |
| 214 DEVICE_LOCAL_ACCOUNT_TYPE_KIOSK_APP); |
| 215 entry->SetStringWithoutPathExpansion( |
| 216 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, |
| 217 "app_1"); |
| 218 device_local_accounts.Append(entry.release()); |
| 219 CrosSettings::Get()->Set(kAccountsPrefDeviceLocalAccounts, |
| 220 device_local_accounts); |
| 206 | 221 |
| 207 AppDataLoadWaiter waiter(manager()); | 222 AppDataLoadWaiter waiter(manager()); |
| 208 waiter.Wait(); | 223 waiter.Wait(); |
| 209 EXPECT_TRUE(waiter.loaded()); | 224 EXPECT_TRUE(waiter.loaded()); |
| 210 | 225 |
| 211 KioskAppManager::Apps apps; | 226 KioskAppManager::Apps apps; |
| 212 manager()->GetApps(&apps); | 227 manager()->GetApps(&apps); |
| 213 EXPECT_EQ(1u, apps.size()); | 228 EXPECT_EQ(1u, apps.size()); |
| 214 EXPECT_EQ("app_1", apps[0].id); | 229 EXPECT_EQ("app_1", apps[0].id); |
| 215 EXPECT_EQ("App1 Name", apps[0].name); | 230 EXPECT_EQ("App1 Name", apps[0].name); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 275 |
| 261 base::FilePath expected_icon_path; | 276 base::FilePath expected_icon_path; |
| 262 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &expected_icon_path)); | 277 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &expected_icon_path)); |
| 263 expected_icon_path = expected_icon_path. | 278 expected_icon_path = expected_icon_path. |
| 264 AppendASCII(KioskAppManager::kIconCacheDir). | 279 AppendASCII(KioskAppManager::kIconCacheDir). |
| 265 AppendASCII(apps[0].id).AddExtension(".png"); | 280 AppendASCII(apps[0].id).AddExtension(".png"); |
| 266 EXPECT_EQ(expected_icon_path.value(), icon_path_string); | 281 EXPECT_EQ(expected_icon_path.value(), icon_path_string); |
| 267 } | 282 } |
| 268 | 283 |
| 269 } // namespace chromeos | 284 } // namespace chromeos |
| OLD | NEW |