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

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

Issue 24707002: Add unit tests for AppListServiceImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, add IsManaged() check 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/profile_loader_unittest.cc
diff --git a/chrome/browser/ui/app_list/profile_loader_unittest.cc b/chrome/browser/ui/app_list/profile_loader_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9ccd79934fb4da8279300e5548e0633fc1e6296d
--- /dev/null
+++ b/chrome/browser/ui/app_list/profile_loader_unittest.cc
@@ -0,0 +1,66 @@
+// 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 "base/bind.h"
+#include "base/files/file_path.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/app_list/profile_loader.h"
+#include "chrome/browser/ui/app_list/test/fake_keep_alive_service.h"
+#include "chrome/browser/ui/app_list/test/fake_profile.h"
+#include "chrome/browser/ui/app_list/test/fake_profile_store.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class ProfileLoaderUnittest : public testing::Test {
+ public:
+ virtual void SetUp() OVERRIDE {
+ last_callback_result_ = NULL;
+ profile1_.reset(
+ new FakeProfile("p1", base::FilePath(FILE_PATH_LITERAL("profile1"))));
+ profile2_.reset(
+ new FakeProfile("p2", base::FilePath(FILE_PATH_LITERAL("profile2"))));
+
+ profile_store_.reset(new FakeProfileStore(
+ base::FilePath(FILE_PATH_LITERAL("udd"))));
+ keep_alive_service_ = new FakeKeepAliveService;
+ loader_.reset(new ProfileLoader(profile_store_.get(),
+ make_scoped_ptr(keep_alive_service_)));
+ }
+
+ virtual void TearDown() OVERRIDE {
+ }
+
+ void OnProfileLoaded(Profile* profile) {
+ last_callback_result_ = profile;
+ }
+
+ FakeKeepAliveService* keep_alive_service_;
+ scoped_ptr<ProfileLoader> loader_;
+ scoped_ptr<FakeProfileStore> profile_store_;
+ scoped_ptr<FakeProfile> profile1_;
+ scoped_ptr<FakeProfile> profile2_;
+ Profile* last_callback_result_;
+};
+
+TEST_F(ProfileLoaderUnittest, LoadASecondProfileBeforeTheFirstFinishes) {
benwells 2013/09/26 06:55:29 Would be good to test InvalidatePendingProfileLoad
benwells 2013/09/26 06:55:29 Also would be good to test this classes interactio
koz (OOO until 15th September) 2013/09/26 22:12:47 Done.
koz (OOO until 15th September) 2013/09/26 22:12:47 Done.
+ EXPECT_FALSE(loader_->IsAnyProfileLoading());
+
+ loader_->LoadProfileInvalidatingOtherLoads(
+ profile1_->GetPath(),
+ base::Bind(&ProfileLoaderUnittest::OnProfileLoaded,
+ base::Unretained(this)));
+ EXPECT_TRUE(loader_->IsAnyProfileLoading());
+ loader_->LoadProfileInvalidatingOtherLoads(
+ profile2_->GetPath(),
+ base::Bind(&ProfileLoaderUnittest::OnProfileLoaded,
+ base::Unretained(this)));
+
+ profile_store_->RunCallbackByPath(profile1_->GetPath(), profile1_.get());
+ EXPECT_EQ(NULL, last_callback_result_);
+
+ profile_store_->RunCallbackByPath(profile2_->GetPath(), profile2_.get());
+ EXPECT_EQ(profile2_.get(), last_callback_result_);
+
+ EXPECT_FALSE(loader_->IsAnyProfileLoading());
+}

Powered by Google App Engine
This is Rietveld 408576698