Chromium Code Reviews| 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/ui/app_list/arc/arc_app_dialog.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_dialog.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 9 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 11 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| 12 #include "chrome/browser/ui/app_list/app_list_service.h" | 12 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 13 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 14 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | 14 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" |
| 15 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 15 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
| 19 #include "chromeos/chromeos_switches.h" | 19 #include "components/arc/arc_util.h" |
| 20 #include "components/arc/common/app.mojom.h" | 20 #include "components/arc/common/app.mojom.h" |
| 21 #include "components/arc/test/fake_app_instance.h" | 21 #include "components/arc/test/fake_app_instance.h" |
| 22 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
| 23 | 23 |
| 24 namespace arc { | 24 namespace arc { |
| 25 | 25 |
| 26 class ArcAppUninstallDialogViewBrowserTest : public InProcessBrowserTest { | 26 class ArcAppUninstallDialogViewBrowserTest : public InProcessBrowserTest { |
| 27 public: | 27 public: |
| 28 ArcAppUninstallDialogViewBrowserTest() {} | 28 ArcAppUninstallDialogViewBrowserTest() {} |
| 29 | 29 |
| 30 // InProcessBrowserTest: | 30 // InProcessBrowserTest: |
| 31 ~ArcAppUninstallDialogViewBrowserTest() override {} | 31 ~ArcAppUninstallDialogViewBrowserTest() override {} |
| 32 | 32 |
| 33 void SetUpAppInstance() { | 33 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 34 InProcessBrowserTest::SetUpCommandLine(command_line); | |
| 35 arc::SetArcAvailableCommandLineForTesting(command_line); | |
| 36 } | |
| 37 | |
| 38 void SetUpInProcessBrowserTestFixture() override { | |
| 39 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | |
| 40 ArcSessionManager::DisableUIForTesting(); | |
| 41 } | |
| 42 | |
| 43 void SetUpOnMainThread() override { | |
| 44 InProcessBrowserTest::SetUpOnMainThread(); | |
| 34 profile_ = browser()->profile(); | 45 profile_ = browser()->profile(); |
| 35 | |
| 36 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 37 chromeos::switches::kEnableArc); | |
| 38 | |
| 39 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | 46 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); |
| 40 if (!arc_app_list_pref_) { | 47 if (!arc_app_list_pref_) { |
| 41 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting( | 48 ArcAppListPrefsFactory::GetInstance()->RecreateServiceInstanceForTesting( |
| 42 profile_); | 49 profile_); |
| 43 } | 50 } |
| 44 | 51 |
| 45 ArcSessionManager* session_manager = ArcSessionManager::Get(); | 52 ArcSessionManager* session_manager = ArcSessionManager::Get(); |
| 46 DCHECK(session_manager); | 53 DCHECK(session_manager); |
| 47 ArcSessionManager::DisableUIForTesting(); | |
| 48 session_manager->OnPrimaryUserProfilePrepared(profile_); | |
|
msw
2017/01/26 18:22:44
q: just checking, is this not needed anymore?
| |
| 49 session_manager->EnableArc(); | 54 session_manager->EnableArc(); |
| 50 | 55 |
| 51 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); | 56 arc_app_list_pref_ = ArcAppListPrefs::Get(profile_); |
| 52 DCHECK(arc_app_list_pref_); | 57 DCHECK(arc_app_list_pref_); |
| 53 | 58 |
| 54 base::RunLoop run_loop; | 59 base::RunLoop run_loop; |
| 55 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); | 60 arc_app_list_pref_->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
| 56 run_loop.Run(); | 61 run_loop.Run(); |
| 57 | 62 |
| 58 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); | 63 app_instance_.reset(new arc::FakeAppInstance(arc_app_list_pref_)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 std::unique_ptr<arc::FakeAppInstance> app_instance_; | 107 std::unique_ptr<arc::FakeAppInstance> app_instance_; |
| 103 | 108 |
| 104 DISALLOW_COPY_AND_ASSIGN(ArcAppUninstallDialogViewBrowserTest); | 109 DISALLOW_COPY_AND_ASSIGN(ArcAppUninstallDialogViewBrowserTest); |
| 105 }; | 110 }; |
| 106 | 111 |
| 107 // User confirms/cancels Arc app uninstall. Note that the shortcut is removed | 112 // User confirms/cancels Arc app uninstall. Note that the shortcut is removed |
| 108 // when the app and the package are uninstalled since the shortcut and the app | 113 // when the app and the package are uninstalled since the shortcut and the app |
| 109 // share same package. | 114 // share same package. |
| 110 IN_PROC_BROWSER_TEST_F(ArcAppUninstallDialogViewBrowserTest, | 115 IN_PROC_BROWSER_TEST_F(ArcAppUninstallDialogViewBrowserTest, |
| 111 UserConfirmsUninstall) { | 116 UserConfirmsUninstall) { |
| 112 SetUpAppInstance(); | |
| 113 | |
| 114 std::vector<std::string> app_ids = arc_app_list_pref()->GetAppIds(); | 117 std::vector<std::string> app_ids = arc_app_list_pref()->GetAppIds(); |
| 115 EXPECT_EQ(app_ids.size(), 2u); | 118 EXPECT_EQ(app_ids.size(), 2u); |
| 116 std::string package_name = base::StringPrintf("fake.package.%d", 0); | 119 std::string package_name = base::StringPrintf("fake.package.%d", 0); |
| 117 std::string app_activity = base::StringPrintf("fake.app.%d.activity", 0); | 120 std::string app_activity = base::StringPrintf("fake.app.%d.activity", 0); |
| 118 std::string app_id = | 121 std::string app_id = |
| 119 arc_app_list_pref()->GetAppId(package_name, app_activity); | 122 arc_app_list_pref()->GetAppId(package_name, app_activity); |
| 120 | 123 |
| 121 AppListService* service = AppListService::Get(); | 124 AppListService* service = AppListService::Get(); |
| 122 ASSERT_TRUE(service); | 125 ASSERT_TRUE(service); |
| 123 service->ShowForProfile(browser()->profile()); | 126 service->ShowForProfile(browser()->profile()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 138 content::RunAllPendingInMessageLoop(); | 141 content::RunAllPendingInMessageLoop(); |
| 139 app_ids = arc_app_list_pref()->GetAppIds(); | 142 app_ids = arc_app_list_pref()->GetAppIds(); |
| 140 EXPECT_EQ(app_ids.size(), 0u); | 143 EXPECT_EQ(app_ids.size(), 0u); |
| 141 controller->DismissView(); | 144 controller->DismissView(); |
| 142 } | 145 } |
| 143 | 146 |
| 144 // User confirms/cancels Arc app shortcut removal. Note that the app is not | 147 // User confirms/cancels Arc app shortcut removal. Note that the app is not |
| 145 // uninstalled when the shortcut is removed. | 148 // uninstalled when the shortcut is removed. |
| 146 IN_PROC_BROWSER_TEST_F(ArcAppUninstallDialogViewBrowserTest, | 149 IN_PROC_BROWSER_TEST_F(ArcAppUninstallDialogViewBrowserTest, |
| 147 UserConfirmsUninstallShortcut) { | 150 UserConfirmsUninstallShortcut) { |
| 148 SetUpAppInstance(); | |
| 149 | |
| 150 std::vector<std::string> app_ids = arc_app_list_pref()->GetAppIds(); | 151 std::vector<std::string> app_ids = arc_app_list_pref()->GetAppIds(); |
| 151 EXPECT_EQ(app_ids.size(), 2u); | 152 EXPECT_EQ(app_ids.size(), 2u); |
| 152 std::string package_name = base::StringPrintf("fake.package.%d", 0); | 153 std::string package_name = base::StringPrintf("fake.package.%d", 0); |
| 153 std::string intent_uri = base::StringPrintf("Fake Shortcut uri %d", 0); | 154 std::string intent_uri = base::StringPrintf("Fake Shortcut uri %d", 0); |
| 154 std::string app_id = arc_app_list_pref()->GetAppId(package_name, intent_uri); | 155 std::string app_id = arc_app_list_pref()->GetAppId(package_name, intent_uri); |
| 155 | 156 |
| 156 AppListService* service = AppListService::Get(); | 157 AppListService* service = AppListService::Get(); |
| 157 ASSERT_TRUE(service); | 158 ASSERT_TRUE(service); |
| 158 service->ShowForProfile(browser()->profile()); | 159 service->ShowForProfile(browser()->profile()); |
| 159 AppListControllerDelegate* controller(service->GetControllerDelegate()); | 160 AppListControllerDelegate* controller(service->GetControllerDelegate()); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 170 content::RunAllPendingInMessageLoop(); | 171 content::RunAllPendingInMessageLoop(); |
| 171 | 172 |
| 172 EXPECT_TRUE(CloseAppDialogViewAndConfirmForTest(true)); | 173 EXPECT_TRUE(CloseAppDialogViewAndConfirmForTest(true)); |
| 173 content::RunAllPendingInMessageLoop(); | 174 content::RunAllPendingInMessageLoop(); |
| 174 app_ids = arc_app_list_pref()->GetAppIds(); | 175 app_ids = arc_app_list_pref()->GetAppIds(); |
| 175 EXPECT_EQ(app_ids.size(), 1u); | 176 EXPECT_EQ(app_ids.size(), 1u); |
| 176 controller->DismissView(); | 177 controller->DismissView(); |
| 177 } | 178 } |
| 178 | 179 |
| 179 } // namespace arc | 180 } // namespace arc |
| OLD | NEW |