Fix build break
[chromium-blink-merge.git] / chrome / browser / plugins / plugin_metadata_unittest.cc
blobb542b1b191def9edef0a61ca127abacdc7a8e308
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
3 // found in the LICENSE file.
5 #include "chrome/browser/plugins/plugin_metadata.h"
7 #include "base/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "webkit/plugins/webplugininfo.h"
11 using webkit::WebPluginInfo;
13 namespace {
15 PluginMetadata::SecurityStatus GetSecurityStatus(
16 PluginMetadata* plugin_metadata,
17 const char* version) {
18 WebPluginInfo plugin(ASCIIToUTF16("Foo plug-in"),
19 base::FilePath(FILE_PATH_LITERAL("/tmp/plugin.so")),
20 ASCIIToUTF16(version),
21 ASCIIToUTF16("Foo plug-in."));
22 return plugin_metadata->GetSecurityStatus(plugin);
25 } // namespace
27 TEST(PluginMetadataTest, SecurityStatus) {
28 const PluginMetadata::SecurityStatus kUpToDate =
29 PluginMetadata::SECURITY_STATUS_UP_TO_DATE;
30 const PluginMetadata::SecurityStatus kOutOfDate =
31 PluginMetadata::SECURITY_STATUS_OUT_OF_DATE;
32 const PluginMetadata::SecurityStatus kRequiresAuthorization =
33 PluginMetadata::SECURITY_STATUS_REQUIRES_AUTHORIZATION;
35 PluginMetadata plugin_metadata("claybrick-writer",
36 ASCIIToUTF16("ClayBrick Writer"),
37 true,
38 GURL(),
39 GURL(),
40 ASCIIToUTF16("ClayBrick"),
41 std::string());
42 #if defined(OS_LINUX)
43 EXPECT_EQ(kRequiresAuthorization,
44 GetSecurityStatus(&plugin_metadata, "1.2.3"));
45 #else
46 EXPECT_EQ(kUpToDate, GetSecurityStatus(&plugin_metadata, "1.2.3"));
47 #endif
49 plugin_metadata.AddVersion(Version("9.4.1"), kRequiresAuthorization);
50 plugin_metadata.AddVersion(Version("10"), kOutOfDate);
51 plugin_metadata.AddVersion(Version("10.2.1"), kUpToDate);
53 // Invalid version.
54 EXPECT_EQ(kOutOfDate, GetSecurityStatus(&plugin_metadata, "foo"));
56 EXPECT_EQ(kOutOfDate, GetSecurityStatus(&plugin_metadata, "0"));
57 EXPECT_EQ(kOutOfDate, GetSecurityStatus(&plugin_metadata, "1.2.3"));
58 EXPECT_EQ(kRequiresAuthorization,
59 GetSecurityStatus(&plugin_metadata, "9.4.1"));
60 EXPECT_EQ(kRequiresAuthorization,
61 GetSecurityStatus(&plugin_metadata, "9.4.2"));
62 EXPECT_EQ(kOutOfDate, GetSecurityStatus(&plugin_metadata, "10.2.0"));
63 EXPECT_EQ(kUpToDate, GetSecurityStatus(&plugin_metadata, "10.2.1"));
64 EXPECT_EQ(kUpToDate, GetSecurityStatus(&plugin_metadata, "11"));