OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/customization_document.h" | 5 #include "chrome/browser/chromeos/customization_document.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/testing_pref_service.h" | 9 #include "base/prefs/testing_pref_service.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" | 12 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
13 #include "chrome/browser/extensions/external_provider_impl.h" | 13 #include "chrome/browser/extensions/external_provider_impl.h" |
14 #include "chrome/browser/prefs/browser_prefs.h" | 14 #include "chrome/browser/prefs/browser_prefs.h" |
15 #include "chrome/browser/prefs/pref_service_mock_factory.h" | 15 #include "chrome/browser/prefs/pref_service_mock_factory.h" |
16 #include "chrome/browser/prefs/pref_service_syncable.h" | 16 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 17 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 18 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
17 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
18 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
19 #include "chromeos/dbus/dbus_thread_manager.h" | 21 #include "chromeos/dbus/dbus_thread_manager.h" |
20 #include "chromeos/network/network_handler.h" | 22 #include "chromeos/network/network_handler.h" |
21 #include "chromeos/system/mock_statistics_provider.h" | 23 #include "chromeos/system/mock_statistics_provider.h" |
22 #include "components/user_prefs/pref_registry_syncable.h" | 24 #include "components/user_prefs/pref_registry_syncable.h" |
23 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
24 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
25 #include "extensions/common/manifest.h" | 27 #include "extensions/common/manifest.h" |
26 #include "net/http/http_response_headers.h" | 28 #include "net/http/http_response_headers.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 74 |
73 const char kBadManifest[] = "{\"version\": \"1\"}"; | 75 const char kBadManifest[] = "{\"version\": \"1\"}"; |
74 | 76 |
75 const char kGoodServicesManifest[] = | 77 const char kGoodServicesManifest[] = |
76 "{" | 78 "{" |
77 " \"version\": \"1.0\"," | 79 " \"version\": \"1.0\"," |
78 " \"default_wallpaper\": \"http://somedomain.com/image.png\",\n" | 80 " \"default_wallpaper\": \"http://somedomain.com/image.png\",\n" |
79 " \"default_apps\": [\n" | 81 " \"default_apps\": [\n" |
80 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n" | 82 " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n" |
81 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n" | 83 " \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"\n" |
82 " ]\n" | 84 " ],\n" |
| 85 " \"localized_content\": {\n" |
| 86 " \"en-US\": {\n" |
| 87 " \"default_apps_folder_name\": \"EN-US OEM Name\"\n" |
| 88 " },\n" |
| 89 " \"en\": {\n" |
| 90 " \"default_apps_folder_name\": \"EN OEM Name\"\n" |
| 91 " },\n" |
| 92 " \"default\": {\n" |
| 93 " \"default_apps_folder_name\": \"Default OEM Name\"\n" |
| 94 " }\n" |
| 95 " }\n" |
83 "}"; | 96 "}"; |
84 | 97 |
85 const char kDummyCustomizationID[] = "test-dummy"; | 98 const char kDummyCustomizationID[] = "test-dummy"; |
86 | 99 |
87 // Note the path name must be the same as in shill stub. | 100 // Note the path name must be the same as in shill stub. |
88 const char kStubEthernetServicePath[] = "eth1"; | 101 const char kStubEthernetServicePath[] = "eth1"; |
89 | 102 |
90 } // anonymous namespace | 103 } // anonymous namespace |
91 | 104 |
92 namespace chromeos { | 105 namespace chromeos { |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 | 323 |
311 EXPECT_EQ(doc->GetDefaultWallpaperUrl().spec(), | 324 EXPECT_EQ(doc->GetDefaultWallpaperUrl().spec(), |
312 "http://somedomain.com/image.png"); | 325 "http://somedomain.com/image.png"); |
313 | 326 |
314 std::vector<std::string> default_apps; | 327 std::vector<std::string> default_apps; |
315 EXPECT_TRUE(doc->GetDefaultApps(&default_apps)); | 328 EXPECT_TRUE(doc->GetDefaultApps(&default_apps)); |
316 ASSERT_EQ(default_apps.size(), 2u); | 329 ASSERT_EQ(default_apps.size(), 2u); |
317 | 330 |
318 EXPECT_EQ(default_apps[0], "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | 331 EXPECT_EQ(default_apps[0], "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |
319 EXPECT_EQ(default_apps[1], "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); | 332 EXPECT_EQ(default_apps[1], "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); |
| 333 |
| 334 EXPECT_EQ(doc->GetOemAppsFolderName("en-US"), "EN-US OEM Name"); |
| 335 EXPECT_EQ(doc->GetOemAppsFolderName("en"), "EN OEM Name"); |
| 336 EXPECT_EQ(doc->GetOemAppsFolderName("ru"), "Default OEM Name"); |
320 } | 337 } |
321 | 338 |
322 TEST_F(ServicesCustomizationDocumentTest, NoCustomizationIdInVpd) { | 339 TEST_F(ServicesCustomizationDocumentTest, NoCustomizationIdInVpd) { |
323 ServicesCustomizationDocument* doc = | 340 ServicesCustomizationDocument* doc = |
324 ServicesCustomizationDocument::GetInstance(); | 341 ServicesCustomizationDocument::GetInstance(); |
325 doc->SetZeroNetworkDelayForTesting(); | 342 doc->SetZeroNetworkDelayForTesting(); |
326 EXPECT_FALSE(doc->IsReady()); | 343 EXPECT_FALSE(doc->IsReady()); |
327 | 344 |
328 scoped_ptr<TestingProfile> profile = CreateProfile(); | 345 scoped_ptr<TestingProfile> profile = CreateProfile(); |
329 extensions::ExternalLoader* loader = doc->CreateExternalLoader(profile.get()); | 346 extensions::ExternalLoader* loader = doc->CreateExternalLoader(profile.get()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 410 |
394 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _)) | 411 EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _)) |
395 .Times(0); | 412 .Times(0); |
396 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _)) | 413 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _)) |
397 .Times(2); | 414 .Times(2); |
398 EXPECT_CALL(visitor, OnExternalProviderReady(_)) | 415 EXPECT_CALL(visitor, OnExternalProviderReady(_)) |
399 .Times(1); | 416 .Times(1); |
400 | 417 |
401 RunUntilIdle(); | 418 RunUntilIdle(); |
402 EXPECT_TRUE(doc->IsReady()); | 419 EXPECT_TRUE(doc->IsReady()); |
| 420 |
| 421 app_list::AppListSyncableService* service = |
| 422 app_list::AppListSyncableServiceFactory::GetForProfile(profile.get()); |
| 423 ASSERT_TRUE(service); |
| 424 EXPECT_EQ(service->GetOemFolderNameForTest(), "EN OEM Name"); |
403 } | 425 } |
404 | 426 |
405 TEST_F(ServicesCustomizationDocumentTest, CustomizationManifestNotFound) { | 427 TEST_F(ServicesCustomizationDocumentTest, CustomizationManifestNotFound) { |
406 AddCustomizationIdToVp(kDummyCustomizationID); | 428 AddCustomizationIdToVp(kDummyCustomizationID); |
407 AddManifestNotFound(kDummyCustomizationID); | 429 AddManifestNotFound(kDummyCustomizationID); |
408 | 430 |
409 ServicesCustomizationDocument* doc = | 431 ServicesCustomizationDocument* doc = |
410 ServicesCustomizationDocument::GetInstance(); | 432 ServicesCustomizationDocument::GetInstance(); |
411 doc->SetZeroNetworkDelayForTesting(); | 433 doc->SetZeroNetworkDelayForTesting(); |
412 EXPECT_FALSE(doc->IsReady()); | 434 EXPECT_FALSE(doc->IsReady()); |
(...skipping 29 matching lines...) Expand all Loading... |
442 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _)) | 464 EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _)) |
443 .Times(0); | 465 .Times(0); |
444 EXPECT_CALL(visitor, OnExternalProviderReady(_)) | 466 EXPECT_CALL(visitor, OnExternalProviderReady(_)) |
445 .Times(1); | 467 .Times(1); |
446 | 468 |
447 RunUntilIdle(); | 469 RunUntilIdle(); |
448 EXPECT_TRUE(doc->IsReady()); | 470 EXPECT_TRUE(doc->IsReady()); |
449 } | 471 } |
450 | 472 |
451 } // namespace chromeos | 473 } // namespace chromeos |
OLD | NEW |