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

Side by Side Diff: chrome/browser/extensions/extension_icon_manager_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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) 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 "base/json/json_file_value_serializer.h" 5 #include "base/json/json_file_value_serializer.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/extension_icon_manager.h" 9 #include "chrome/browser/extensions/extension_icon_manager.h"
10 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
(...skipping 17 matching lines...) Expand all
28 waiting_(false), 28 waiting_(false),
29 ui_thread_(BrowserThread::UI, &ui_loop_), 29 ui_thread_(BrowserThread::UI, &ui_loop_),
30 file_thread_(BrowserThread::FILE), 30 file_thread_(BrowserThread::FILE),
31 io_thread_(BrowserThread::IO) {} 31 io_thread_(BrowserThread::IO) {}
32 32
33 virtual ~ExtensionIconManagerTest() {} 33 virtual ~ExtensionIconManagerTest() {}
34 34
35 void ImageLoadObserved() { 35 void ImageLoadObserved() {
36 unwaited_image_loads_++; 36 unwaited_image_loads_++;
37 if (waiting_) { 37 if (waiting_) {
38 MessageLoop::current()->Quit(); 38 base::MessageLoop::current()->Quit();
39 } 39 }
40 } 40 }
41 41
42 void WaitForImageLoad() { 42 void WaitForImageLoad() {
43 if (unwaited_image_loads_ == 0) { 43 if (unwaited_image_loads_ == 0) {
44 waiting_ = true; 44 waiting_ = true;
45 MessageLoop::current()->Run(); 45 base::MessageLoop::current()->Run();
46 waiting_ = false; 46 waiting_ = false;
47 } 47 }
48 ASSERT_GT(unwaited_image_loads_, 0); 48 ASSERT_GT(unwaited_image_loads_, 0);
49 unwaited_image_loads_--; 49 unwaited_image_loads_--;
50 } 50 }
51 51
52 private: 52 private:
53 virtual void SetUp() { 53 virtual void SetUp() {
54 file_thread_.Start(); 54 file_thread_.Start();
55 io_thread_.Start(); 55 io_thread_.Start();
56 } 56 }
57 57
58 // The number of observed image loads that have not been waited for. 58 // The number of observed image loads that have not been waited for.
59 int unwaited_image_loads_; 59 int unwaited_image_loads_;
60 60
61 // Whether we are currently waiting for an image load. 61 // Whether we are currently waiting for an image load.
62 bool waiting_; 62 bool waiting_;
63 63
64 MessageLoop ui_loop_; 64 base::MessageLoop ui_loop_;
65 content::TestBrowserThread ui_thread_; 65 content::TestBrowserThread ui_thread_;
66 content::TestBrowserThread file_thread_; 66 content::TestBrowserThread file_thread_;
67 content::TestBrowserThread io_thread_; 67 content::TestBrowserThread io_thread_;
68 68
69 DISALLOW_COPY_AND_ASSIGN(ExtensionIconManagerTest); 69 DISALLOW_COPY_AND_ASSIGN(ExtensionIconManagerTest);
70 }; 70 };
71 71
72 // This is a specialization of ExtensionIconManager, with a special override to 72 // This is a specialization of ExtensionIconManager, with a special override to
73 // call back to the test when an icon has completed loading. 73 // call back to the test when an icon has completed loading.
74 class TestIconManager : public ExtensionIconManager { 74 class TestIconManager : public ExtensionIconManager {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // Now re-load the icon - we should get the same result bitmap (and not the 174 // Now re-load the icon - we should get the same result bitmap (and not the
175 // default icon). 175 // default icon).
176 icon_manager.LoadIcon(profile.get(), extension.get()); 176 icon_manager.LoadIcon(profile.get(), extension.get());
177 WaitForImageLoad(); 177 WaitForImageLoad();
178 SkBitmap second_icon = icon_manager.GetIcon(extension->id()); 178 SkBitmap second_icon = icon_manager.GetIcon(extension->id());
179 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon)); 179 EXPECT_FALSE(gfx::BitmapsAreEqual(second_icon, default_icon));
180 180
181 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon)); 181 EXPECT_TRUE(gfx::BitmapsAreEqual(first_icon, second_icon));
182 } 182 }
183 #endif 183 #endif
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_icon_image_unittest.cc ('k') | chrome/browser/extensions/extension_info_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698