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/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" | 14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" |
| 15 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 16 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
15 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 17 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
16 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "net/base/host_port_pair.h" | 21 #include "net/base/host_port_pair.h" |
20 #include "net/dns/mock_host_resolver.h" | 22 #include "net/dns/mock_host_resolver.h" |
21 | 23 |
22 namespace chromeos { | 24 namespace chromeos { |
23 | 25 |
24 namespace { | 26 namespace { |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 apps_dict->SetString("app_1.name", "App1 Name"); | 188 apps_dict->SetString("app_1.name", "App1 Name"); |
187 std::string icon_path = | 189 std::string icon_path = |
188 base::StringPrintf("%s/red16x16.png", data_dir.value().c_str()); | 190 base::StringPrintf("%s/red16x16.png", data_dir.value().c_str()); |
189 apps_dict->SetString("app_1.icon", icon_path); | 191 apps_dict->SetString("app_1.icon", icon_path); |
190 | 192 |
191 PrefService* local_state = g_browser_process->local_state(); | 193 PrefService* local_state = g_browser_process->local_state(); |
192 DictionaryPrefUpdate dict_update(local_state, | 194 DictionaryPrefUpdate dict_update(local_state, |
193 KioskAppManager::kKioskDictionaryName); | 195 KioskAppManager::kKioskDictionaryName); |
194 dict_update->Set(KioskAppManager::kKeyApps, apps_dict.release()); | 196 dict_update->Set(KioskAppManager::kKeyApps, apps_dict.release()); |
195 | 197 |
196 // Triggers reload prefs. | 198 // Make the app appear in device settings. |
197 manager()->RemoveApp("dummy"); | 199 base::ListValue device_local_accounts; |
| 200 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| 201 entry->SetStringWithoutPathExpansion( |
| 202 kAccountsPrefDeviceLocalAccountsKeyId, |
| 203 "app_1_id"); |
| 204 entry->SetIntegerWithoutPathExpansion( |
| 205 kAccountsPrefDeviceLocalAccountsKeyType, |
| 206 DEVICE_LOCAL_ACCOUNT_TYPE_KIOSK_APP); |
| 207 entry->SetStringWithoutPathExpansion( |
| 208 kAccountsPrefDeviceLocalAccountsKeyKioskAppId, |
| 209 "app_1"); |
| 210 device_local_accounts.Append(entry.release()); |
| 211 CrosSettings::Get()->Set(kAccountsPrefDeviceLocalAccounts, |
| 212 device_local_accounts); |
198 | 213 |
199 AppDataLoadWaiter waiter(manager()); | 214 AppDataLoadWaiter waiter(manager()); |
200 waiter.Wait(); | 215 waiter.Wait(); |
201 EXPECT_TRUE(waiter.loaded()); | 216 EXPECT_TRUE(waiter.loaded()); |
202 | 217 |
203 KioskAppManager::Apps apps; | 218 KioskAppManager::Apps apps; |
204 manager()->GetApps(&apps); | 219 manager()->GetApps(&apps); |
205 EXPECT_EQ(1u, apps.size()); | 220 EXPECT_EQ(1u, apps.size()); |
206 EXPECT_EQ("app_1", apps[0].id); | 221 EXPECT_EQ("app_1", apps[0].id); |
207 EXPECT_EQ("App1 Name", apps[0].name); | 222 EXPECT_EQ("App1 Name", apps[0].name); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 267 |
253 base::FilePath expected_icon_path; | 268 base::FilePath expected_icon_path; |
254 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &expected_icon_path)); | 269 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_DATA, &expected_icon_path)); |
255 expected_icon_path = expected_icon_path. | 270 expected_icon_path = expected_icon_path. |
256 AppendASCII(KioskAppManager::kIconCacheDir). | 271 AppendASCII(KioskAppManager::kIconCacheDir). |
257 AppendASCII(apps[0].id).AddExtension(".png"); | 272 AppendASCII(apps[0].id).AddExtension(".png"); |
258 EXPECT_EQ(expected_icon_path.value(), icon_path_string); | 273 EXPECT_EQ(expected_icon_path.value(), icon_path_string); |
259 } | 274 } |
260 | 275 |
261 } // namespace chromeos | 276 } // namespace chromeos |
OLD | NEW |