| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/profiles/profile_info_cache_unittest.h" | 5 #include "chrome/browser/profiles/profile_info_cache_unittest.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 kIconIndex, GetCache()->GetPathOfProfileAtIndex(0), GetCache()); | 564 kIconIndex, GetCache()->GetPathOfProfileAtIndex(0), GetCache()); |
| 565 | 565 |
| 566 // Put a real bitmap into "bitmap". 2x2 bitmap of green 32 bit pixels. | 566 // Put a real bitmap into "bitmap". 2x2 bitmap of green 32 bit pixels. |
| 567 SkBitmap bitmap; | 567 SkBitmap bitmap; |
| 568 bitmap.allocN32Pixels(2, 2); | 568 bitmap.allocN32Pixels(2, 2); |
| 569 bitmap.eraseColor(SK_ColorGREEN); | 569 bitmap.eraseColor(SK_ColorGREEN); |
| 570 | 570 |
| 571 avatar_downloader.OnFetchComplete( | 571 avatar_downloader.OnFetchComplete( |
| 572 GURL("http://www.google.com/avatar.png"), &bitmap); | 572 GURL("http://www.google.com/avatar.png"), &bitmap); |
| 573 | 573 |
| 574 // Now the download should not be in progress anymore. |
| 575 EXPECT_EQ(0U, GetCache()->avatar_images_downloads_in_progress_.size()); |
| 576 |
| 574 std::string file_name = | 577 std::string file_name = |
| 575 profiles::GetDefaultAvatarIconFileNameAtIndex(kIconIndex); | 578 profiles::GetDefaultAvatarIconFileNameAtIndex(kIconIndex); |
| 576 | 579 |
| 577 // The file should have been cached and saved. | 580 // The file should have been cached and saved. |
| 578 EXPECT_EQ(1U, GetCache()->avatar_images_downloads_in_progress_.size()); | |
| 579 EXPECT_EQ(1U, GetCache()->cached_avatar_images_.size()); | 581 EXPECT_EQ(1U, GetCache()->cached_avatar_images_.size()); |
| 580 EXPECT_TRUE(GetCache()->GetHighResAvatarOfProfileAtIndex(0)); | 582 EXPECT_TRUE(GetCache()->GetHighResAvatarOfProfileAtIndex(0)); |
| 581 EXPECT_EQ(GetCache()->cached_avatar_images_[file_name], | 583 EXPECT_EQ(GetCache()->cached_avatar_images_[file_name], |
| 582 GetCache()->GetHighResAvatarOfProfileAtIndex(0)); | 584 GetCache()->GetHighResAvatarOfProfileAtIndex(0)); |
| 583 | 585 |
| 584 // Make sure everything has completed, and the file has been written to disk. | 586 // Make sure everything has completed, and the file has been written to disk. |
| 585 base::RunLoop().RunUntilIdle(); | 587 base::RunLoop().RunUntilIdle(); |
| 586 | 588 |
| 587 // Clean up. | 589 // Clean up. |
| 588 base::FilePath icon_path = | 590 base::FilePath icon_path = |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 // Profile names should have been preserved. | 672 // Profile names should have been preserved. |
| 671 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( | 673 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( |
| 672 GetCache()->GetIndexOfProfileWithPath(path_1))); | 674 GetCache()->GetIndexOfProfileWithPath(path_1))); |
| 673 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( | 675 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( |
| 674 GetCache()->GetIndexOfProfileWithPath(path_2))); | 676 GetCache()->GetIndexOfProfileWithPath(path_2))); |
| 675 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( | 677 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( |
| 676 GetCache()->GetIndexOfProfileWithPath(path_3))); | 678 GetCache()->GetIndexOfProfileWithPath(path_3))); |
| 677 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( | 679 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( |
| 678 GetCache()->GetIndexOfProfileWithPath(path_4))); | 680 GetCache()->GetIndexOfProfileWithPath(path_4))); |
| 679 } | 681 } |
| OLD | NEW |