Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Side by Side Diff: chrome/browser/chromeos/note_taking_helper_unittest.cc

Issue 2777253002: chromeos: Update note-taking apps when ARC-enabled profile added. (Closed)
Patch Set: add TODO Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/note_taking_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/arc_util.h" 33 #include "components/arc/arc_util.h"
31 #include "components/arc/common/intent_helper.mojom.h" 34 #include "components/arc/common/intent_helper.mojom.h"
32 #include "components/arc/test/fake_intent_helper_instance.h" 35 #include "components/arc/test/fake_intent_helper_instance.h"
33 #include "components/crx_file/id_util.h" 36 #include "components/crx_file/id_util.h"
37 #include "components/sync_preferences/testing_pref_service_syncable.h"
34 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
35 #include "content/public/browser/notification_source.h" 39 #include "content/public/browser/notification_source.h"
36 #include "extensions/common/api/app_runtime.h" 40 #include "extensions/common/api/app_runtime.h"
37 #include "extensions/common/extension_builder.h" 41 #include "extensions/common/extension_builder.h"
38 #include "extensions/common/extension_id.h" 42 #include "extensions/common/extension_id.h"
39 #include "extensions/common/value_builder.h" 43 #include "extensions/common/value_builder.h"
40 #include "url/gurl.h" 44 #include "url/gurl.h"
41 45
42 namespace app_runtime = extensions::api::app_runtime; 46 namespace app_runtime = extensions::api::app_runtime;
43 47
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 EXPECT_FALSE(helper()->android_apps_received()); 494 EXPECT_FALSE(helper()->android_apps_received());
491 495
492 // After the callback to receive intent handlers has run, the "apps received" 496 // After the callback to receive intent handlers has run, the "apps received"
493 // member should be updated (even if there aren't any apps). 497 // member should be updated (even if there aren't any apps).
494 helper()->OnIntentFiltersUpdated(); 498 helper()->OnIntentFiltersUpdated();
495 base::RunLoop().RunUntilIdle(); 499 base::RunLoop().RunUntilIdle();
496 EXPECT_TRUE(helper()->play_store_enabled()); 500 EXPECT_TRUE(helper()->play_store_enabled());
497 EXPECT_TRUE(helper()->android_apps_received()); 501 EXPECT_TRUE(helper()->android_apps_received());
498 } 502 }
499 503
504 TEST_P(NoteTakingHelperTest, AddProfileWithPlayStoreEnabled) {
505 Init(ENABLE_PALETTE);
506 EXPECT_FALSE(helper()->play_store_enabled());
507 EXPECT_FALSE(helper()->android_apps_received());
508
509 TestObserver observer;
510 ASSERT_EQ(0, observer.num_updates());
511
512 // Add a second profile with the ARC-enabled pref already set. The Play Store
513 // should be immediately regarded as being enabled and the observer should be
514 // notified, since OnArcPlayStoreEnabledChanged() apparently isn't called in
515 // this case: http://crbug.com/700554
516 const char kSecondProfileName[] = "second-profile";
517 auto prefs = base::MakeUnique<sync_preferences::TestingPrefServiceSyncable>();
518 chrome::RegisterUserProfilePrefs(prefs->registry());
519 prefs->SetBoolean(prefs::kArcEnabled, true);
520 profile_manager_->CreateTestingProfile(
521 kSecondProfileName, std::move(prefs), base::ASCIIToUTF16("Second User"),
522 1 /* avatar_id */, std::string() /* supervised_user_id */,
523 TestingProfile::TestingFactories());
524 EXPECT_TRUE(helper()->play_store_enabled());
525 EXPECT_FALSE(helper()->android_apps_received());
526 EXPECT_EQ(1, observer.num_updates());
527
528 // Notification of updated intent filters should result in the apps being
529 // refreshed.
530 helper()->OnIntentFiltersUpdated();
531 base::RunLoop().RunUntilIdle();
532 EXPECT_TRUE(helper()->play_store_enabled());
533 EXPECT_TRUE(helper()->android_apps_received());
534 EXPECT_EQ(2, observer.num_updates());
535
536 profile_manager_->DeleteTestingProfile(kSecondProfileName);
537 }
538
500 TEST_P(NoteTakingHelperTest, ListAndroidApps) { 539 TEST_P(NoteTakingHelperTest, ListAndroidApps) {
501 // Add two Android apps. 540 // Add two Android apps.
502 std::vector<IntentHandlerInfoPtr> handlers; 541 std::vector<IntentHandlerInfoPtr> handlers;
503 const std::string kName1 = "App 1"; 542 const std::string kName1 = "App 1";
504 const std::string kPackage1 = "org.chromium.package1"; 543 const std::string kPackage1 = "org.chromium.package1";
505 handlers.emplace_back(CreateIntentHandlerInfo(kName1, kPackage1)); 544 handlers.emplace_back(CreateIntentHandlerInfo(kName1, kPackage1));
506 const std::string kName2 = "App 2"; 545 const std::string kName2 = "App 2";
507 const std::string kPackage2 = "org.chromium.package2"; 546 const std::string kPackage2 = "org.chromium.package2";
508 handlers.emplace_back(CreateIntentHandlerInfo(kName2, kPackage2)); 547 handlers.emplace_back(CreateIntentHandlerInfo(kName2, kPackage2));
509 intent_helper_.SetIntentHandlers(NoteTakingHelper::kIntentAction, 548 intent_helper_.SetIntentHandlers(NoteTakingHelper::kIntentAction,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 InitExtensionService(second_profile); 748 InitExtensionService(second_profile);
710 EXPECT_EQ(0, observer.num_updates()); 749 EXPECT_EQ(0, observer.num_updates());
711 InstallExtension(keep_extension.get(), second_profile); 750 InstallExtension(keep_extension.get(), second_profile);
712 EXPECT_EQ(1, observer.num_updates()); 751 EXPECT_EQ(1, observer.num_updates());
713 UninstallExtension(keep_extension.get(), second_profile); 752 UninstallExtension(keep_extension.get(), second_profile);
714 EXPECT_EQ(2, observer.num_updates()); 753 EXPECT_EQ(2, observer.num_updates());
715 profile_manager_->DeleteTestingProfile(kSecondProfileName); 754 profile_manager_->DeleteTestingProfile(kSecondProfileName);
716 } 755 }
717 756
718 } // namespace chromeos 757 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/note_taking_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698