| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/note_taking_helper.h" | 5 #include "chrome/browser/chromeos/note_taking_helper.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/test/histogram_tester.h" | 18 #include "base/test/histogram_tester.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/chromeos/file_manager/path_util.h" | 20 #include "chrome/browser/chromeos/file_manager/path_util.h" |
| 19 #include "chrome/browser/extensions/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/test_extension_system.h" | 22 #include "chrome/browser/extensions/test_extension_system.h" |
| 23 #include "chrome/browser/prefs/browser_prefs.h" |
| 21 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" | 24 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" |
| 22 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/test/base/browser_with_test_window_test.h" | 26 #include "chrome/test/base/browser_with_test_window_test.h" |
| 24 #include "chrome/test/base/testing_browser_process.h" | 27 #include "chrome/test/base/testing_browser_process.h" |
| 25 #include "chrome/test/base/testing_profile_manager.h" | 28 #include "chrome/test/base/testing_profile_manager.h" |
| 26 #include "chromeos/dbus/dbus_thread_manager.h" | 29 #include "chromeos/dbus/dbus_thread_manager.h" |
| 27 #include "chromeos/dbus/fake_session_manager_client.h" | 30 #include "chromeos/dbus/fake_session_manager_client.h" |
| 28 #include "components/arc/arc_bridge_service.h" | 31 #include "components/arc/arc_bridge_service.h" |
| 29 #include "components/arc/arc_service_manager.h" | 32 #include "components/arc/arc_service_manager.h" |
| 30 #include "components/arc/common/intent_helper.mojom.h" | 33 #include "components/arc/common/intent_helper.mojom.h" |
| 31 #include "components/arc/test/fake_intent_helper_instance.h" | 34 #include "components/arc/test/fake_intent_helper_instance.h" |
| 32 #include "components/crx_file/id_util.h" | 35 #include "components/crx_file/id_util.h" |
| 36 #include "components/sync_preferences/testing_pref_service_syncable.h" |
| 33 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 34 #include "content/public/browser/notification_source.h" | 38 #include "content/public/browser/notification_source.h" |
| 35 #include "extensions/common/api/app_runtime.h" | 39 #include "extensions/common/api/app_runtime.h" |
| 36 #include "extensions/common/extension_builder.h" | 40 #include "extensions/common/extension_builder.h" |
| 37 #include "extensions/common/extension_id.h" | 41 #include "extensions/common/extension_id.h" |
| 38 #include "extensions/common/value_builder.h" | 42 #include "extensions/common/value_builder.h" |
| 39 #include "url/gurl.h" | 43 #include "url/gurl.h" |
| 40 | 44 |
| 41 namespace app_runtime = extensions::api::app_runtime; | 45 namespace app_runtime = extensions::api::app_runtime; |
| 42 | 46 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 EXPECT_FALSE(helper()->android_apps_received()); | 482 EXPECT_FALSE(helper()->android_apps_received()); |
| 479 | 483 |
| 480 // After the callback to receive intent handlers has run, the "apps received" | 484 // After the callback to receive intent handlers has run, the "apps received" |
| 481 // member should be updated (even if there aren't any apps). | 485 // member should be updated (even if there aren't any apps). |
| 482 helper()->OnIntentFiltersUpdated(); | 486 helper()->OnIntentFiltersUpdated(); |
| 483 base::RunLoop().RunUntilIdle(); | 487 base::RunLoop().RunUntilIdle(); |
| 484 EXPECT_TRUE(helper()->android_enabled()); | 488 EXPECT_TRUE(helper()->android_enabled()); |
| 485 EXPECT_TRUE(helper()->android_apps_received()); | 489 EXPECT_TRUE(helper()->android_apps_received()); |
| 486 } | 490 } |
| 487 | 491 |
| 488 TEST_F(NoteTakingHelperTest, ListAndroidApps) { | 492 TEST_F(NoteTakingHelperTest, AddProfileWithPlayStoreEnabled) { |
| 493 Init(ENABLE_PALETTE); |
| 494 EXPECT_FALSE(helper()->play_store_enabled()); |
| 495 EXPECT_FALSE(helper()->android_apps_received()); |
| 496 |
| 497 TestObserver observer; |
| 498 ASSERT_EQ(0, observer.num_updates()); |
| 499 |
| 500 // Add a second profile with the ARC-enabled pref already set. The Play Store |
| 501 // should be immediately regarded as being enabled and the observer should be |
| 502 // notified, since OnArcPlayStoreEnabledChanged() apparently isn't called in |
| 503 // this case: http://crbug.com/700554 |
| 504 const char kSecondProfileName[] = "second-profile"; |
| 505 auto prefs = base::MakeUnique<sync_preferences::TestingPrefServiceSyncable>(); |
| 506 chrome::RegisterUserProfilePrefs(prefs->registry()); |
| 507 prefs->SetBoolean(prefs::kArcEnabled, true); |
| 508 profile_manager_->CreateTestingProfile( |
| 509 kSecondProfileName, std::move(prefs), base::ASCIIToUTF16("Second User"), |
| 510 1 /* avatar_id */, std::string() /* supervised_user_id */, |
| 511 TestingProfile::TestingFactories()); |
| 512 EXPECT_TRUE(helper()->play_store_enabled()); |
| 513 EXPECT_FALSE(helper()->android_apps_received()); |
| 514 EXPECT_EQ(1, observer.num_updates()); |
| 515 |
| 516 // Notification of updated intent filters should result in the apps being |
| 517 // refreshed. |
| 518 helper()->OnIntentFiltersUpdated(); |
| 519 base::RunLoop().RunUntilIdle(); |
| 520 EXPECT_TRUE(helper()->play_store_enabled()); |
| 521 EXPECT_TRUE(helper()->android_apps_received()); |
| 522 EXPECT_EQ(2, observer.num_updates()); |
| 523 |
| 524 profile_manager_->DeleteTestingProfile(kSecondProfileName); |
| 525 } |
| 526 |
| 527 TEST_P(NoteTakingHelperTest, ListAndroidApps) { |
| 489 // Add two Android apps. | 528 // Add two Android apps. |
| 490 std::vector<IntentHandlerInfoPtr> handlers; | 529 std::vector<IntentHandlerInfoPtr> handlers; |
| 491 const std::string kName1 = "App 1"; | 530 const std::string kName1 = "App 1"; |
| 492 const std::string kPackage1 = "org.chromium.package1"; | 531 const std::string kPackage1 = "org.chromium.package1"; |
| 493 handlers.emplace_back(CreateIntentHandlerInfo(kName1, kPackage1)); | 532 handlers.emplace_back(CreateIntentHandlerInfo(kName1, kPackage1)); |
| 494 const std::string kName2 = "App 2"; | 533 const std::string kName2 = "App 2"; |
| 495 const std::string kPackage2 = "org.chromium.package2"; | 534 const std::string kPackage2 = "org.chromium.package2"; |
| 496 handlers.emplace_back(CreateIntentHandlerInfo(kName2, kPackage2)); | 535 handlers.emplace_back(CreateIntentHandlerInfo(kName2, kPackage2)); |
| 497 intent_helper_.SetIntentHandlers(NoteTakingHelper::kIntentAction, | 536 intent_helper_.SetIntentHandlers(NoteTakingHelper::kIntentAction, |
| 498 std::move(handlers)); | 537 std::move(handlers)); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 InitExtensionService(second_profile); | 727 InitExtensionService(second_profile); |
| 689 EXPECT_EQ(0, observer.num_updates()); | 728 EXPECT_EQ(0, observer.num_updates()); |
| 690 InstallExtension(keep_extension.get(), second_profile); | 729 InstallExtension(keep_extension.get(), second_profile); |
| 691 EXPECT_EQ(1, observer.num_updates()); | 730 EXPECT_EQ(1, observer.num_updates()); |
| 692 UninstallExtension(keep_extension.get(), second_profile); | 731 UninstallExtension(keep_extension.get(), second_profile); |
| 693 EXPECT_EQ(2, observer.num_updates()); | 732 EXPECT_EQ(2, observer.num_updates()); |
| 694 profile_manager_->DeleteTestingProfile(kSecondProfileName); | 733 profile_manager_->DeleteTestingProfile(kSecondProfileName); |
| 695 } | 734 } |
| 696 | 735 |
| 697 } // namespace chromeos | 736 } // namespace chromeos |
| OLD | NEW |