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

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

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 "chrome/browser/extensions/image_loader.h" 5 #include "chrome/browser/extensions/image_loader.h"
6 6
7 #include "base/json/json_file_value_serializer.h" 7 #include "base/json/json_file_value_serializer.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
(...skipping 26 matching lines...) Expand all
37 : image_loaded_count_(0), 37 : image_loaded_count_(0),
38 quit_in_image_loaded_(false), 38 quit_in_image_loaded_(false),
39 ui_thread_(BrowserThread::UI, &ui_loop_), 39 ui_thread_(BrowserThread::UI, &ui_loop_),
40 file_thread_(BrowserThread::FILE), 40 file_thread_(BrowserThread::FILE),
41 io_thread_(BrowserThread::IO) { 41 io_thread_(BrowserThread::IO) {
42 } 42 }
43 43
44 void OnImageLoaded(const gfx::Image& image) { 44 void OnImageLoaded(const gfx::Image& image) {
45 image_loaded_count_++; 45 image_loaded_count_++;
46 if (quit_in_image_loaded_) 46 if (quit_in_image_loaded_)
47 MessageLoop::current()->Quit(); 47 base::MessageLoop::current()->Quit();
48 image_ = image; 48 image_ = image;
49 } 49 }
50 50
51 void WaitForImageLoad() { 51 void WaitForImageLoad() {
52 quit_in_image_loaded_ = true; 52 quit_in_image_loaded_ = true;
53 MessageLoop::current()->Run(); 53 base::MessageLoop::current()->Run();
54 quit_in_image_loaded_ = false; 54 quit_in_image_loaded_ = false;
55 } 55 }
56 56
57 int image_loaded_count() { 57 int image_loaded_count() {
58 int result = image_loaded_count_; 58 int result = image_loaded_count_;
59 image_loaded_count_ = 0; 59 image_loaded_count_ = 0;
60 return result; 60 return result;
61 } 61 }
62 62
63 scoped_refptr<Extension> CreateExtension(const char* name, 63 scoped_refptr<Extension> CreateExtension(const char* name,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 file_thread_.Start(); 105 file_thread_.Start();
106 io_thread_.Start(); 106 io_thread_.Start();
107 } 107 }
108 108
109 virtual void TearDown() OVERRIDE { 109 virtual void TearDown() OVERRIDE {
110 extensions::ManifestHandler::ClearRegistryForTesting(); 110 extensions::ManifestHandler::ClearRegistryForTesting();
111 } 111 }
112 112
113 int image_loaded_count_; 113 int image_loaded_count_;
114 bool quit_in_image_loaded_; 114 bool quit_in_image_loaded_;
115 MessageLoop ui_loop_; 115 base::MessageLoop ui_loop_;
116 content::TestBrowserThread ui_thread_; 116 content::TestBrowserThread ui_thread_;
117 content::TestBrowserThread file_thread_; 117 content::TestBrowserThread file_thread_;
118 content::TestBrowserThread io_thread_; 118 content::TestBrowserThread io_thread_;
119 }; 119 };
120 120
121 // Tests loading an image works correctly. 121 // Tests loading an image works correctly.
122 TEST_F(ImageLoaderTest, LoadImage) { 122 TEST_F(ImageLoaderTest, LoadImage) {
123 scoped_refptr<Extension> extension(CreateExtension( 123 scoped_refptr<Extension> extension(CreateExtension(
124 "image_loading_tracker", Manifest::INVALID_LOCATION)); 124 "image_loading_tracker", Manifest::INVALID_LOCATION));
125 ASSERT_TRUE(extension.get() != NULL); 125 ASSERT_TRUE(extension.get() != NULL);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 258
259 #if defined(FILE_MANAGER_EXTENSION) 259 #if defined(FILE_MANAGER_EXTENSION)
260 int resource_id; 260 int resource_id;
261 ASSERT_EQ(true, 261 ASSERT_EQ(true,
262 ImageLoader::IsComponentExtensionResource(extension->path(), 262 ImageLoader::IsComponentExtensionResource(extension->path(),
263 resource.relative_path(), 263 resource.relative_path(),
264 &resource_id)); 264 &resource_id));
265 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); 265 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id);
266 #endif 266 #endif
267 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698