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