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/strings/utf_string_conversions.h"
8 #include "content/public/common/webplugininfo.h"
9 #include "testing/gtest/include/gtest/gtest.h"
13 PluginMetadata::SecurityStatus
GetSecurityStatus(
14 PluginMetadata
* plugin_metadata
,
15 const char* version
) {
16 content::WebPluginInfo
plugin(
17 base::ASCIIToUTF16("Foo plugin"),
18 base::FilePath(FILE_PATH_LITERAL("/tmp/plugin.so")),
19 base::ASCIIToUTF16(version
),
20 base::ASCIIToUTF16("Foo plugin."));
21 return plugin_metadata
->GetSecurityStatus(plugin
);
26 TEST(PluginMetadataTest
, SecurityStatus
) {
27 const PluginMetadata::SecurityStatus kUpToDate
=
28 PluginMetadata::SECURITY_STATUS_UP_TO_DATE
;
29 const PluginMetadata::SecurityStatus kOutOfDate
=
30 PluginMetadata::SECURITY_STATUS_OUT_OF_DATE
;
31 const PluginMetadata::SecurityStatus kRequiresAuthorization
=
32 PluginMetadata::SECURITY_STATUS_REQUIRES_AUTHORIZATION
;
34 PluginMetadata
plugin_metadata("claybrick-writer",
35 base::ASCIIToUTF16("ClayBrick Writer"),
39 base::ASCIIToUTF16("ClayBrick"),
41 EXPECT_EQ(kRequiresAuthorization
,
42 GetSecurityStatus(&plugin_metadata
, "1.2.3"));
44 plugin_metadata
.AddVersion(Version("9.4.1"), kRequiresAuthorization
);
45 plugin_metadata
.AddVersion(Version("10"), kOutOfDate
);
46 plugin_metadata
.AddVersion(Version("10.2.1"), kUpToDate
);
49 EXPECT_EQ(kOutOfDate
, GetSecurityStatus(&plugin_metadata
, "foo"));
51 EXPECT_EQ(kOutOfDate
, GetSecurityStatus(&plugin_metadata
, "0"));
52 EXPECT_EQ(kOutOfDate
, GetSecurityStatus(&plugin_metadata
, "1.2.3"));
53 EXPECT_EQ(kRequiresAuthorization
,
54 GetSecurityStatus(&plugin_metadata
, "9.4.1"));
55 EXPECT_EQ(kRequiresAuthorization
,
56 GetSecurityStatus(&plugin_metadata
, "9.4.2"));
57 EXPECT_EQ(kOutOfDate
, GetSecurityStatus(&plugin_metadata
, "10.2.0"));
58 EXPECT_EQ(kUpToDate
, GetSecurityStatus(&plugin_metadata
, "10.2.1"));
59 EXPECT_EQ(kUpToDate
, GetSecurityStatus(&plugin_metadata
, "11"));