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

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: 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 "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 25 matching lines...) Expand all
36 : image_loaded_count_(0), 36 : image_loaded_count_(0),
37 quit_in_image_loaded_(false), 37 quit_in_image_loaded_(false),
38 ui_thread_(BrowserThread::UI, &ui_loop_), 38 ui_thread_(BrowserThread::UI, &ui_loop_),
39 file_thread_(BrowserThread::FILE), 39 file_thread_(BrowserThread::FILE),
40 io_thread_(BrowserThread::IO) { 40 io_thread_(BrowserThread::IO) {
41 } 41 }
42 42
43 void OnImageLoaded(const gfx::Image& image) { 43 void OnImageLoaded(const gfx::Image& image) {
44 image_loaded_count_++; 44 image_loaded_count_++;
45 if (quit_in_image_loaded_) 45 if (quit_in_image_loaded_)
46 MessageLoop::current()->Quit(); 46 base::MessageLoop::current()->Quit();
47 image_ = image; 47 image_ = image;
48 } 48 }
49 49
50 void WaitForImageLoad() { 50 void WaitForImageLoad() {
51 quit_in_image_loaded_ = true; 51 quit_in_image_loaded_ = true;
52 MessageLoop::current()->Run(); 52 base::MessageLoop::current()->Run();
53 quit_in_image_loaded_ = false; 53 quit_in_image_loaded_ = false;
54 } 54 }
55 55
56 int image_loaded_count() { 56 int image_loaded_count() {
57 int result = image_loaded_count_; 57 int result = image_loaded_count_;
58 image_loaded_count_ = 0; 58 image_loaded_count_ = 0;
59 return result; 59 return result;
60 } 60 }
61 61
62 scoped_refptr<Extension> CreateExtension(const char* name, 62 scoped_refptr<Extension> CreateExtension(const char* name,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 private: 99 private:
100 virtual void SetUp() OVERRIDE { 100 virtual void SetUp() OVERRIDE {
101 testing::Test::SetUp(); 101 testing::Test::SetUp();
102 file_thread_.Start(); 102 file_thread_.Start();
103 io_thread_.Start(); 103 io_thread_.Start();
104 } 104 }
105 105
106 int image_loaded_count_; 106 int image_loaded_count_;
107 bool quit_in_image_loaded_; 107 bool quit_in_image_loaded_;
108 MessageLoop ui_loop_; 108 base::MessageLoop ui_loop_;
109 content::TestBrowserThread ui_thread_; 109 content::TestBrowserThread ui_thread_;
110 content::TestBrowserThread file_thread_; 110 content::TestBrowserThread file_thread_;
111 content::TestBrowserThread io_thread_; 111 content::TestBrowserThread io_thread_;
112 }; 112 };
113 113
114 // Tests loading an image works correctly. 114 // Tests loading an image works correctly.
115 TEST_F(ImageLoaderTest, LoadImage) { 115 TEST_F(ImageLoaderTest, LoadImage) {
116 scoped_refptr<Extension> extension(CreateExtension( 116 scoped_refptr<Extension> extension(CreateExtension(
117 "image_loading_tracker", Manifest::INVALID_LOCATION)); 117 "image_loading_tracker", Manifest::INVALID_LOCATION));
118 ASSERT_TRUE(extension.get() != NULL); 118 ASSERT_TRUE(extension.get() != NULL);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 251
252 #if defined(FILE_MANAGER_EXTENSION) 252 #if defined(FILE_MANAGER_EXTENSION)
253 int resource_id; 253 int resource_id;
254 ASSERT_EQ(true, 254 ASSERT_EQ(true,
255 ImageLoader::IsComponentExtensionResource(extension->path(), 255 ImageLoader::IsComponentExtensionResource(extension->path(),
256 resource.relative_path(), 256 resource.relative_path(),
257 &resource_id)); 257 &resource_id));
258 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id); 258 ASSERT_EQ(IDR_FILE_MANAGER_ICON_16, resource_id);
259 #endif 259 #endif
260 } 260 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_policy_loader_unittest.cc ('k') | chrome/browser/extensions/installed_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698