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
;
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
);
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"),
40 ASCIIToUTF16("ClayBrick"),
43 EXPECT_EQ(kRequiresAuthorization
,
44 GetSecurityStatus(&plugin_metadata
, "1.2.3"));
46 EXPECT_EQ(kUpToDate
, GetSecurityStatus(&plugin_metadata
, "1.2.3"));
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
);
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"));