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

Unified Diff: chrome/browser/ui/app_list/test/fake_profile_store.cc

Issue 24707002: Add unit tests for AppListServiceImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: un-const an iterator Created 7 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/test/fake_profile_store.cc
diff --git a/chrome/browser/ui/app_list/test/fake_profile_store.cc b/chrome/browser/ui/app_list/test/fake_profile_store.cc
new file mode 100644
index 0000000000000000000000000000000000000000..85e46e189f822d795c56b916556a3043572dbcaa
--- /dev/null
+++ b/chrome/browser/ui/app_list/test/fake_profile_store.cc
@@ -0,0 +1,64 @@
+// Copyright 2013 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/test/fake_profile_store.h"
+
+#include "chrome/browser/profiles/profile.h"
+
+FakeProfileStore::FakeProfileStore(const base::FilePath& user_data_dir)
+ : user_data_dir_(user_data_dir) {
+}
+
+FakeProfileStore::~FakeProfileStore() {
+}
+
+void FakeProfileStore::LoadProfile(Profile* profile) {
+ loaded_profiles_[profile->GetPath()] = profile;
+ CallbacksByPath::iterator it = callbacks_.find(profile->GetPath());
+ if (it != callbacks_.end()) {
+ it->second.Run(profile);
+ callbacks_.erase(it);
+ }
+}
+
+void FakeProfileStore::RemoveProfile(Profile* profile) {
+ base::FilePath path(profile->GetPath());
+ FOR_EACH_OBSERVER(ProfileInfoCacheObserver, observer_list_,
+ OnProfileWillBeRemoved(path));
+ loaded_profiles_.erase(path);
+ FOR_EACH_OBSERVER(ProfileInfoCacheObserver, observer_list_,
+ OnProfileWasRemoved(path, base::string16()));
+}
+
+void FakeProfileStore::AddProfileObserver(
+ ProfileInfoCacheObserver* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void FakeProfileStore::LoadProfileAsync(
+ const base::FilePath& path,
+ base::Callback<void(Profile*)> callback) {
+ Profile* profile = GetProfileByPath(path);
+ if (profile) {
+ callback.Run(profile);
+ return;
+ }
+ callbacks_[path] = callback;
+}
+
+Profile* FakeProfileStore::GetProfileByPath(
+ const base::FilePath& path) {
+ ProfilesByPath::const_iterator it = loaded_profiles_.find(path);
+ if (it != loaded_profiles_.end())
+ return it->second;
+ return NULL;
+}
+
+base::FilePath FakeProfileStore::GetUserDataDir() {
+ return user_data_dir_;
+}
+
+bool FakeProfileStore::IsProfileManaged(const base::FilePath& path) {
+ return false;
+}
« no previous file with comments | « chrome/browser/ui/app_list/test/fake_profile_store.h ('k') | chrome/browser/ui/views/app_list/app_list_controller_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698