| 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/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  Loading... | 
|   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  Loading... | 
|   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  Loading... | 
|  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 } | 
| OLD | NEW |