| 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 "content/child/npapi/plugin_lib.h" | 5 #include "content/child/npapi/plugin_lib.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 // Test the unloading of plugin libs. Bug http://crbug.com/46526 showed that | 14 // Test the unloading of plugin libs. Bug http://crbug.com/46526 showed that |
| 15 // if UnloadAllPlugins() simply iterates through the g_loaded_libs global | 15 // if UnloadAllPlugins() simply iterates through the g_loaded_libs global |
| 16 // variable, we can get a crash if no plugin libs were marked as always loaded. | 16 // variable, we can get a crash if no plugin libs were marked as always loaded. |
| 17 class PluginLibTest : public PluginLib { | 17 class PluginLibTest : public PluginLib { |
| 18 public: | 18 public: |
| 19 PluginLibTest() : PluginLib(WebPluginInfo()) {} | 19 PluginLibTest() : PluginLib(WebPluginInfo()) {} |
| 20 using PluginLib::Unload; | 20 using PluginLib::Unload; |
| 21 | 21 |
| 22 protected: | 22 protected: |
| 23 virtual ~PluginLibTest() {} | 23 ~PluginLibTest() override {} |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 TEST(PluginLibLoading, UnloadAllPlugins) { | 26 TEST(PluginLibLoading, UnloadAllPlugins) { |
| 27 // For the creation of the g_loaded_libs global variable. | 27 // For the creation of the g_loaded_libs global variable. |
| 28 ASSERT_EQ(static_cast<PluginLibTest*>(NULL), | 28 ASSERT_EQ(static_cast<PluginLibTest*>(NULL), |
| 29 PluginLibTest::CreatePluginLib(base::FilePath())); | 29 PluginLibTest::CreatePluginLib(base::FilePath())); |
| 30 | 30 |
| 31 // Try with a single plugin lib. | 31 // Try with a single plugin lib. |
| 32 scoped_refptr<PluginLibTest> plugin_lib1(new PluginLibTest()); | 32 scoped_refptr<PluginLibTest> plugin_lib1(new PluginLibTest()); |
| 33 PluginLib::UnloadAllPlugins(); | 33 PluginLib::UnloadAllPlugins(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 55 ASSERT_EQ(static_cast<PluginLibTest*>(NULL), | 55 ASSERT_EQ(static_cast<PluginLibTest*>(NULL), |
| 56 PluginLibTest::CreatePluginLib(base::FilePath())); | 56 PluginLibTest::CreatePluginLib(base::FilePath())); |
| 57 | 57 |
| 58 // Now try to manually Unload the only one and then UnloadAll. | 58 // Now try to manually Unload the only one and then UnloadAll. |
| 59 plugin_lib1 = new PluginLibTest(); | 59 plugin_lib1 = new PluginLibTest(); |
| 60 plugin_lib1->Unload(); | 60 plugin_lib1->Unload(); |
| 61 PluginLib::UnloadAllPlugins(); | 61 PluginLib::UnloadAllPlugins(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace content | 64 } // namespace content |
| OLD | NEW |