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

Unified Diff: chrome/browser/ui/app_list/app_list_service_impl_browsertest.cc

Issue 552153002: Adds AppListServiceImplBrowserTest.ShowLoadedProfiles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20140908-AppList-ALVD-SpeechUI-fromcl
Patch Set: respond to commments Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/app_list_service_impl_browsertest.cc
diff --git a/chrome/browser/ui/app_list/app_list_service_impl_browsertest.cc b/chrome/browser/ui/app_list/app_list_service_impl_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a54b8ced6734fffd33ad6d5b853424675e1bcf07
--- /dev/null
+++ b/chrome/browser/ui/app_list/app_list_service_impl_browsertest.cc
@@ -0,0 +1,104 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/app_list/app_list_service_impl.h"
+
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/app_list/test/chrome_app_list_test_support.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/base/in_process_browser_test.h"
+
+namespace test {
+
+// Test API to access private members of AppListServiceImpl.
+class AppListServiceImplTestApi {
+ public:
+ explicit AppListServiceImplTestApi(AppListServiceImpl* impl) : impl_(impl) {}
+
+ ProfileLoader* profile_loader() { return impl_->profile_loader_.get(); }
+
+ private:
+ AppListServiceImpl* impl_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppListServiceImplTestApi);
+};
+
+} // namespace test
+
+// Browser Test for AppListServiceImpl that runs on all platforms supporting
+// app_list.
+class AppListServiceImplBrowserTest : public InProcessBrowserTest {
+ public:
+ AppListServiceImplBrowserTest() {}
+
+ // Overridden from InProcessBrowserTest:
+ virtual void SetUpOnMainThread() OVERRIDE {
+ service_ = test::GetAppListServiceImpl();
+ test_api_.reset(new test::AppListServiceImplTestApi(service_));
+ }
+
+ protected:
+ AppListServiceImpl* service_;
+ scoped_ptr<test::AppListServiceImplTestApi> test_api_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AppListServiceImplBrowserTest);
+};
+
+// Test that showing a loaded profile for the first time is lazy and
+// synchronous. Then tests that showing a second loaded profile without
+// dismissing correctly switches profiles.
+IN_PROC_BROWSER_TEST_F(AppListServiceImplBrowserTest, ShowLoadedProfiles) {
+ PrefService* local_state = g_browser_process->local_state();
+ EXPECT_FALSE(local_state->HasPrefPath(prefs::kAppListProfile));
+
+ // When never shown, profile path should match the last used profile.
+ base::FilePath user_data_dir =
+ g_browser_process->profile_manager()->user_data_dir();
+ EXPECT_EQ(service_->GetProfilePath(user_data_dir),
+ browser()->profile()->GetPath());
+
+ // Just requesting the profile path shouldn't set it.
+ EXPECT_FALSE(local_state->HasPrefPath(prefs::kAppListProfile));
+
+ // Loading the Profile* should be lazy, except on ChromeOS where it is bound
+ // to ChromeLauncherController, which always has a profile.
+#if defined(OS_CHROMEOS)
+ EXPECT_TRUE(service_->GetCurrentAppListProfile());
+#else
+ EXPECT_FALSE(service_->GetCurrentAppListProfile());
+#endif
+
+ // Showing the app list for an unspecified profile, uses the loaded profile.
+ service_->Show();
+
+ // Load should be synchronous.
+ EXPECT_FALSE(test_api_->profile_loader()->IsAnyProfileLoading());
+ EXPECT_EQ(service_->GetCurrentAppListProfile(), browser()->profile());
+
+#if defined(OS_CHROMEOS)
+ // ChromeOS doesn't record the app list profile pref, and doesn't do profile
+ // switching.
+ EXPECT_FALSE(local_state->HasPrefPath(prefs::kAppListProfile));
+
+#else
+ // Preference should be updated automatically.
+ EXPECT_TRUE(local_state->HasPrefPath(prefs::kAppListProfile));
+ EXPECT_EQ(local_state->GetString(prefs::kAppListProfile),
+ browser()->profile()->GetPath().BaseName().MaybeAsASCII());
+
+ // Show for a second, pre-loaded profile without dismissing. Don't try this on
+ // ChromeOS because it does not support profile switching the app list.
+ Profile* profile2 = test::CreateSecondProfileAsync();
+ service_->ShowForProfile(profile2);
+
+ // Current profile and saved path should update synchronously.
+ EXPECT_FALSE(test_api_->profile_loader()->IsAnyProfileLoading());
+ EXPECT_EQ(profile2->GetPath(), service_->GetProfilePath(user_data_dir));
+ EXPECT_EQ(profile2, service_->GetCurrentAppListProfile());
+#endif
+}
« no previous file with comments | « chrome/browser/ui/app_list/app_list_service_impl.h ('k') | chrome/browser/ui/app_list/app_list_service_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698