Chromium Code Reviews| 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.
|
| +} |