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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/background/background_mode_manager.h" 8 #include "chrome/browser/background/background_mode_manager.h"
8 #include "chrome/browser/profiles/profile_info_cache.h" 9 #include "chrome/browser/profiles/profile_info_cache.h"
9 #include "chrome/browser/ui/browser_list.h" 10 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
11 #include "chrome/test/base/testing_browser_process.h" 12 #include "chrome/test/base/testing_browser_process.h"
12 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
13 #include "chrome/test/base/testing_profile_manager.h" 14 #include "chrome/test/base/testing_profile_manager.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 class BackgroundModeManagerTest : public testing::Test { 17 class BackgroundModeManagerTest : public testing::Test {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 manager.SetBackgroundAppCountForProfile(0); 242 manager.SetBackgroundAppCountForProfile(0);
242 manager.OnApplicationListChanged(profile2); 243 manager.OnApplicationListChanged(profile2);
243 244
244 size_t p2_index = cache->GetIndexOfProfileWithPath(profile1->GetPath()); 245 size_t p2_index = cache->GetIndexOfProfileWithPath(profile1->GetPath());
245 EXPECT_FALSE(cache->GetBackgroundStatusOfProfileAtIndex(p2_index)); 246 EXPECT_FALSE(cache->GetBackgroundStatusOfProfileAtIndex(p2_index));
246 247
247 // Even though neither has background status on, there should still be two 248 // Even though neither has background status on, there should still be two
248 // profiles in the cache. 249 // profiles in the cache.
249 EXPECT_EQ(2u, cache->GetNumberOfProfiles()); 250 EXPECT_EQ(2u, cache->GetNumberOfProfiles());
250 } 251 }
252 TEST_F(BackgroundModeManagerTest, ProfileInfoCacheObserver) {
253 TestingProfile* profile1 = profile_manager_.CreateTestingProfile("p1");
254 TestBackgroundModeManager manager(
255 command_line_.get(), profile_manager_.profile_info_cache());
256 manager.RegisterProfile(profile1);
257 EXPECT_FALSE(BrowserList::WillKeepAlive());
258
259 ProfileInfoCache* cache = profile_manager_.profile_info_cache();
260
261 // Install app, should show status tray icon.
262 manager.OnBackgroundAppInstalled(NULL);
263 manager.SetBackgroundAppCount(1);
264 manager.SetBackgroundAppCountForProfile(1);
265 manager.OnApplicationListChanged(profile1);
266
267 string16 p1name = cache->GetNameOfProfileAtIndex(0);
268 manager.OnProfileNameChanged(p1name, UTF8ToUTF16("p1new"));
269
270 EXPECT_EQ(UTF8ToUTF16("p1new"), manager.BackgroundModeDataName(profile1));
271
272 TestingProfile* profile2 = profile_manager_.CreateTestingProfile("p2");
273 manager.RegisterProfile(profile2);
274 EXPECT_EQ(2, manager.NumberOfBackgroundModeData());
275
276 manager.OnProfileAdded(UTF8ToUTF16("p2new"),
277 profile2->GetPath().BaseName().LossyDisplayName());
278 EXPECT_EQ(UTF8ToUTF16("p2new"), manager.BackgroundModeDataName(profile2));
279
280 manager.OnProfileRemoved(UTF8ToUTF16("p2new"));
281 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.
282 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698