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

Side by Side Diff: webkit/plugins/npapi/plugin_list_unittest.cc

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« no previous file with comments | « webkit/plugins/npapi/plugin_list_posix.cc ('k') | webkit/plugins/npapi/plugin_list_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/plugins/npapi/plugin_list.h" 5 #include "webkit/plugins/npapi/plugin_list.h"
6 6
7 #include "base/string16.h" 7 #include "base/string16.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "webkit/plugins/npapi/mock_plugin_list.h" 10 #include "webkit/plugins/npapi/mock_plugin_list.h"
(...skipping 13 matching lines...) Expand all
24 bool Contains(const std::vector<WebPluginInfo>& list, 24 bool Contains(const std::vector<WebPluginInfo>& list,
25 const WebPluginInfo& plugin) { 25 const WebPluginInfo& plugin) {
26 for (std::vector<WebPluginInfo>::const_iterator it = list.begin(); 26 for (std::vector<WebPluginInfo>::const_iterator it = list.begin();
27 it != list.end(); ++it) { 27 it != list.end(); ++it) {
28 if (Equals(*it, plugin)) 28 if (Equals(*it, plugin))
29 return true; 29 return true;
30 } 30 }
31 return false; 31 return false;
32 } 32 }
33 33
34 FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin"); 34 base::FilePath::CharType kFooPath[] = FILE_PATH_LITERAL("/plugins/foo.plugin");
35 FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin"); 35 base::FilePath::CharType kBarPath[] = FILE_PATH_LITERAL("/plugins/bar.plugin");
36 const char* kFooName = "Foo Plugin"; 36 const char* kFooName = "Foo Plugin";
37 37
38 } // namespace 38 } // namespace
39 39
40 class PluginListTest : public testing::Test { 40 class PluginListTest : public testing::Test {
41 public: 41 public:
42 PluginListTest() 42 PluginListTest()
43 : foo_plugin_(ASCIIToUTF16(kFooName), 43 : foo_plugin_(ASCIIToUTF16(kFooName),
44 FilePath(kFooPath), 44 base::FilePath(kFooPath),
45 ASCIIToUTF16("1.2.3"), 45 ASCIIToUTF16("1.2.3"),
46 ASCIIToUTF16("foo")), 46 ASCIIToUTF16("foo")),
47 bar_plugin_(ASCIIToUTF16("Bar Plugin"), 47 bar_plugin_(ASCIIToUTF16("Bar Plugin"),
48 FilePath(kBarPath), 48 base::FilePath(kBarPath),
49 ASCIIToUTF16("2.3.4"), 49 ASCIIToUTF16("2.3.4"),
50 ASCIIToUTF16("bar")) { 50 ASCIIToUTF16("bar")) {
51 } 51 }
52 52
53 virtual void SetUp() { 53 virtual void SetUp() {
54 plugin_list_.AddPluginToLoad(bar_plugin_); 54 plugin_list_.AddPluginToLoad(bar_plugin_);
55 plugin_list_.AddPluginToLoad(foo_plugin_); 55 plugin_list_.AddPluginToLoad(foo_plugin_);
56 } 56 }
57 57
58 protected: 58 protected:
59 MockPluginList plugin_list_; 59 MockPluginList plugin_list_;
60 WebPluginInfo foo_plugin_; 60 WebPluginInfo foo_plugin_;
61 WebPluginInfo bar_plugin_; 61 WebPluginInfo bar_plugin_;
62 }; 62 };
63 63
64 TEST_F(PluginListTest, GetPlugins) { 64 TEST_F(PluginListTest, GetPlugins) {
65 std::vector<WebPluginInfo> plugins; 65 std::vector<WebPluginInfo> plugins;
66 plugin_list_.GetPlugins(&plugins); 66 plugin_list_.GetPlugins(&plugins);
67 EXPECT_EQ(2u, plugins.size()); 67 EXPECT_EQ(2u, plugins.size());
68 EXPECT_TRUE(Contains(plugins, foo_plugin_)); 68 EXPECT_TRUE(Contains(plugins, foo_plugin_));
69 EXPECT_TRUE(Contains(plugins, bar_plugin_)); 69 EXPECT_TRUE(Contains(plugins, bar_plugin_));
70 } 70 }
71 71
72 TEST_F(PluginListTest, BadPluginDescription) { 72 TEST_F(PluginListTest, BadPluginDescription) {
73 WebPluginInfo plugin_3043( 73 WebPluginInfo plugin_3043(
74 string16(), FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")), 74 string16(), base::FilePath(FILE_PATH_LITERAL("/myplugin.3.0.43")),
75 string16(), string16()); 75 string16(), string16());
76 // Simulate loading of the plugins. 76 // Simulate loading of the plugins.
77 plugin_list_.ClearPluginsToLoad(); 77 plugin_list_.ClearPluginsToLoad();
78 plugin_list_.AddPluginToLoad(plugin_3043); 78 plugin_list_.AddPluginToLoad(plugin_3043);
79 // Now we should have them in the state we specified above. 79 // Now we should have them in the state we specified above.
80 plugin_list_.RefreshPlugins(); 80 plugin_list_.RefreshPlugins();
81 std::vector<WebPluginInfo> plugins; 81 std::vector<WebPluginInfo> plugins;
82 plugin_list_.GetPlugins(&plugins); 82 plugin_list_.GetPlugins(&plugins);
83 ASSERT_TRUE(Contains(plugins, plugin_3043)); 83 ASSERT_TRUE(Contains(plugins, plugin_3043));
84 } 84 }
85 85
86 } // namespace npapi 86 } // namespace npapi
87 } // namespace webkit 87 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/plugin_list_posix.cc ('k') | webkit/plugins/npapi/plugin_list_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698