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

Unified Diff: chrome/browser/background/background_mode_manager_unittest.cc

Issue 8802013: Fixing background mode manager to correctly display the name of the profile in the status icon. P... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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/background/background_mode_manager_unittest.cc
===================================================================
--- chrome/browser/background/background_mode_manager_unittest.cc (revision 111700)
+++ chrome/browser/background/background_mode_manager_unittest.cc (working copy)
@@ -4,6 +4,7 @@
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/background/background_mode_manager.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/ui/browser_list.h"
@@ -248,3 +249,34 @@
// profiles in the cache.
EXPECT_EQ(2u, cache->GetNumberOfProfiles());
}
+TEST_F(BackgroundModeManagerTest, ProfileInfoCacheObserver) {
+ TestingProfile* profile1 = profile_manager_.CreateTestingProfile("p1");
+ TestBackgroundModeManager manager(
+ command_line_.get(), profile_manager_.profile_info_cache());
+ manager.RegisterProfile(profile1);
+ EXPECT_FALSE(BrowserList::WillKeepAlive());
+
+ ProfileInfoCache* cache = profile_manager_.profile_info_cache();
+
+ // Install app, should show status tray icon.
+ manager.OnBackgroundAppInstalled(NULL);
+ manager.SetBackgroundAppCount(1);
+ manager.SetBackgroundAppCountForProfile(1);
+ manager.OnApplicationListChanged(profile1);
+
+ string16 p1name = cache->GetNameOfProfileAtIndex(0);
+ manager.OnProfileNameChanged(p1name, UTF8ToUTF16("p1new"));
+
+ EXPECT_EQ(UTF8ToUTF16("p1new"), manager.BackgroundModeDataName(profile1));
+
+ TestingProfile* profile2 = profile_manager_.CreateTestingProfile("p2");
+ manager.RegisterProfile(profile2);
+ EXPECT_EQ(2, manager.NumberOfBackgroundModeData());
+
+ manager.OnProfileAdded(UTF8ToUTF16("p2new"),
+ profile2->GetPath().BaseName().LossyDisplayName());
+ EXPECT_EQ(UTF8ToUTF16("p2new"), manager.BackgroundModeDataName(profile2));
+
+ manager.OnProfileRemoved(UTF8ToUTF16("p2new"));
+ EXPECT_EQ(1, manager.NumberOfBackgroundModeData());
Andrew T Wilson (Slow) 2011/12/06 06:46:02 I like this test - it covers all the cases. One mi
rpetterson 2011/12/06 20:09:05 That's a good idea. Done.
+}

Powered by Google App Engine
This is Rietveld 408576698