| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/plugin_loader_posix.h" | 5 #include "content/browser/plugin_loader_posix.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "content/test/test_browser_thread.h" | 12 #include "content/browser/browser_thread_impl.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "webkit/plugins/webplugininfo.h" | 15 #include "webkit/plugins/webplugininfo.h" |
| 16 | 16 |
| 17 using content::BrowserThreadImpl; |
| 18 |
| 17 class MockPluginLoaderPosix : public PluginLoaderPosix { | 19 class MockPluginLoaderPosix : public PluginLoaderPosix { |
| 18 public: | 20 public: |
| 19 MOCK_METHOD0(LoadPluginsInternal, void(void)); | 21 MOCK_METHOD0(LoadPluginsInternal, void(void)); |
| 20 | 22 |
| 21 size_t number_of_pending_callbacks() { | 23 size_t number_of_pending_callbacks() { |
| 22 return callbacks_.size(); | 24 return callbacks_.size(); |
| 23 } | 25 } |
| 24 | 26 |
| 25 std::vector<FilePath>* canonical_list() { | 27 std::vector<FilePath>* canonical_list() { |
| 26 return &canonical_list_; | 28 return &canonical_list_; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 plugin_loader_->canonical_list()->push_back(plugin3_.path); | 77 plugin_loader_->canonical_list()->push_back(plugin3_.path); |
| 76 } | 78 } |
| 77 | 79 |
| 78 // Data used for testing. | 80 // Data used for testing. |
| 79 webkit::WebPluginInfo plugin1_; | 81 webkit::WebPluginInfo plugin1_; |
| 80 webkit::WebPluginInfo plugin2_; | 82 webkit::WebPluginInfo plugin2_; |
| 81 webkit::WebPluginInfo plugin3_; | 83 webkit::WebPluginInfo plugin3_; |
| 82 | 84 |
| 83 private: | 85 private: |
| 84 MessageLoopForIO message_loop_; | 86 MessageLoopForIO message_loop_; |
| 85 content::TestBrowserThread file_thread_; | 87 BrowserThreadImpl file_thread_; |
| 86 content::TestBrowserThread io_thread_; | 88 BrowserThreadImpl io_thread_; |
| 87 | 89 |
| 88 scoped_refptr<MockPluginLoaderPosix> plugin_loader_; | 90 scoped_refptr<MockPluginLoaderPosix> plugin_loader_; |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 TEST_F(PluginLoaderPosixTest, QueueRequests) { | 93 TEST_F(PluginLoaderPosixTest, QueueRequests) { |
| 92 int did_callback = 0; | 94 int did_callback = 0; |
| 93 PluginService::GetPluginsCallback callback = | 95 PluginService::GetPluginsCallback callback = |
| 94 base::Bind(&VerifyCallback, base::Unretained(&did_callback)); | 96 base::Bind(&VerifyCallback, base::Unretained(&did_callback)); |
| 95 | 97 |
| 96 EXPECT_EQ(0u, plugin_loader()->number_of_pending_callbacks()); | 98 EXPECT_EQ(0u, plugin_loader()->number_of_pending_callbacks()); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 message_loop()->RunAllPending(); | 271 message_loop()->RunAllPending(); |
| 270 EXPECT_EQ(0, did_callback); | 272 EXPECT_EQ(0, did_callback); |
| 271 | 273 |
| 272 plugin_loader()->TestOnPluginLoaded(plugin3_); | 274 plugin_loader()->TestOnPluginLoaded(plugin3_); |
| 273 EXPECT_EQ(3u, plugins.size()); | 275 EXPECT_EQ(3u, plugins.size()); |
| 274 EXPECT_EQ(plugin3_.name, plugins[2].name); | 276 EXPECT_EQ(plugin3_.name, plugins[2].name); |
| 275 | 277 |
| 276 message_loop()->RunAllPending(); | 278 message_loop()->RunAllPending(); |
| 277 EXPECT_EQ(1, did_callback); | 279 EXPECT_EQ(1, did_callback); |
| 278 } | 280 } |
| OLD | NEW |