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

Side by Side Diff: chrome/browser/background/background_mode_manager_unittest.cc

Issue 9271018: Merge 115621 - Refactor ProfileInfoCacheObserver interface and usage thereof. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/963/src/
Patch Set: Created 8 years, 11 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 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 "base/utf_string_conversions.h"
8 #include "chrome/browser/background/background_mode_manager.h" 8 #include "chrome/browser/background/background_mode_manager.h"
9 #include "chrome/browser/profiles/profile_info_cache.h" 9 #include "chrome/browser/profiles/profile_info_cache.h"
10 #include "chrome/browser/ui/browser_list.h" 10 #include "chrome/browser/ui/browser_list.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // profiles in the cache. 251 // profiles in the cache.
252 EXPECT_EQ(2u, cache->GetNumberOfProfiles()); 252 EXPECT_EQ(2u, cache->GetNumberOfProfiles());
253 } 253 }
254 TEST_F(BackgroundModeManagerTest, ProfileInfoCacheObserver) { 254 TEST_F(BackgroundModeManagerTest, ProfileInfoCacheObserver) {
255 TestingProfile* profile1 = profile_manager_.CreateTestingProfile("p1"); 255 TestingProfile* profile1 = profile_manager_.CreateTestingProfile("p1");
256 TestBackgroundModeManager manager( 256 TestBackgroundModeManager manager(
257 command_line_.get(), profile_manager_.profile_info_cache()); 257 command_line_.get(), profile_manager_.profile_info_cache());
258 manager.RegisterProfile(profile1); 258 manager.RegisterProfile(profile1);
259 EXPECT_FALSE(BrowserList::WillKeepAlive()); 259 EXPECT_FALSE(BrowserList::WillKeepAlive());
260 260
261 ProfileInfoCache* cache = profile_manager_.profile_info_cache();
262
263 // Install app, should show status tray icon. 261 // Install app, should show status tray icon.
264 manager.OnBackgroundAppInstalled(NULL); 262 manager.OnBackgroundAppInstalled(NULL);
265 manager.SetBackgroundAppCount(1); 263 manager.SetBackgroundAppCount(1);
266 manager.SetBackgroundAppCountForProfile(1); 264 manager.SetBackgroundAppCountForProfile(1);
267 manager.OnApplicationListChanged(profile1); 265 manager.OnApplicationListChanged(profile1);
268 266
269 string16 p1name = cache->GetNameOfProfileAtIndex(0); 267 manager.OnProfileNameChanged(
270 manager.OnProfileNameChanged(p1name, UTF8ToUTF16("p1new")); 268 profile1->GetPath(),
269 manager.GetBackgroundModeData(profile1)->name());
271 270
272 EXPECT_EQ(UTF8ToUTF16("p1new"), 271 EXPECT_EQ(UTF8ToUTF16("p1"),
273 manager.GetBackgroundModeData(profile1)->name()); 272 manager.GetBackgroundModeData(profile1)->name());
274 273
275 TestingProfile* profile2 = profile_manager_.CreateTestingProfile("p2"); 274 TestingProfile* profile2 = profile_manager_.CreateTestingProfile("p2");
276 manager.RegisterProfile(profile2); 275 manager.RegisterProfile(profile2);
277 EXPECT_EQ(2, manager.NumberOfBackgroundModeData()); 276 EXPECT_EQ(2, manager.NumberOfBackgroundModeData());
278 277
279 gfx::Image gaia_image(gfx::test::CreateImage()); 278 manager.OnProfileAdded(profile2->GetPath());
280 manager.OnProfileAdded(UTF8ToUTF16("p2new"), 279 EXPECT_EQ(UTF8ToUTF16("p2"),
281 profile2->GetPath().BaseName().LossyDisplayName(),
282 profile2->GetPath(),
283 &gaia_image);
284 EXPECT_EQ(UTF8ToUTF16("p2new"),
285 manager.GetBackgroundModeData(profile2)->name()); 280 manager.GetBackgroundModeData(profile2)->name());
286 281
287 manager.OnProfileWillBeRemoved(UTF8ToUTF16("p2new")); 282 manager.OnProfileWillBeRemoved(profile2->GetPath());
288 EXPECT_EQ(1, manager.NumberOfBackgroundModeData()); 283 EXPECT_EQ(1, manager.NumberOfBackgroundModeData());
289 284
290 // Check that the background mode data we think is in the map actually is. 285 // Check that the background mode data we think is in the map actually is.
291 EXPECT_EQ(UTF8ToUTF16("p1new"), 286 EXPECT_EQ(UTF8ToUTF16("p1"),
292 manager.GetBackgroundModeData(profile1)->name()); 287 manager.GetBackgroundModeData(profile1)->name());
293 } 288 }
OLDNEW
« no previous file with comments | « chrome/browser/background/background_mode_manager.cc ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698