OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "chrome/browser/plugin_installer.h" | |
6 | |
7 #include "base/utf_string_conversions.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 #include "webkit/plugins/webplugininfo.h" | |
10 | |
11 using webkit::WebPluginInfo; | |
12 | |
13 namespace { | |
14 | |
15 PluginInstaller::SecurityStatus GetSecurityStatus(PluginInstaller* installer, | |
16 const char* version) { | |
17 WebPluginInfo plugin(ASCIIToUTF16("Foo plug-in"), | |
18 FilePath(FILE_PATH_LITERAL("/tmp/plugin.so")), | |
19 ASCIIToUTF16(version), | |
20 ASCIIToUTF16("Foo plug-in.")); | |
21 return installer->GetSecurityStatus(plugin); | |
22 } | |
23 | |
24 } // namespace | |
25 | |
26 TEST(PluginInstallerTest, SecurityStatus) { | |
27 const PluginInstaller::SecurityStatus kUpToDate = | |
28 PluginInstaller::SECURITY_STATUS_UP_TO_DATE; | |
29 const PluginInstaller::SecurityStatus kOutOfDate = | |
30 PluginInstaller::SECURITY_STATUS_OUT_OF_DATE; | |
31 const PluginInstaller::SecurityStatus kRequiresAuthorization = | |
32 PluginInstaller::SECURITY_STATUS_REQUIRES_AUTHORIZATION; | |
33 | |
34 PluginInstaller installer("claybrick-writer", | |
35 ASCIIToUTF16("ClayBrick Writer"), | |
36 true, GURL(), GURL(), ASCIIToUTF16("ClayBrick")); | |
37 | |
38 #if defined(OS_LINUX) | |
39 EXPECT_EQ(kRequiresAuthorization, GetSecurityStatus(&installer, "1.2.3")); | |
40 #else | |
41 EXPECT_EQ(kUpToDate, GetSecurityStatus(&installer, "1.2.3")); | |
42 #endif | |
43 | |
44 installer.AddVersion(Version("9.4.1"), kRequiresAuthorization); | |
45 installer.AddVersion(Version("10"), kOutOfDate); | |
46 installer.AddVersion(Version("10.2.1"), kUpToDate); | |
47 | |
48 // Invalid version. | |
49 EXPECT_EQ(kOutOfDate, GetSecurityStatus(&installer, "foo")); | |
50 | |
51 EXPECT_EQ(kOutOfDate, GetSecurityStatus(&installer, "0")); | |
52 EXPECT_EQ(kOutOfDate, GetSecurityStatus(&installer, "1.2.3")); | |
53 EXPECT_EQ(kRequiresAuthorization, GetSecurityStatus(&installer, "9.4.1")); | |
54 EXPECT_EQ(kRequiresAuthorization, GetSecurityStatus(&installer, "9.4.2")); | |
55 EXPECT_EQ(kOutOfDate, GetSecurityStatus(&installer, "10.2.0")); | |
56 EXPECT_EQ(kUpToDate, GetSecurityStatus(&installer, "10.2.1")); | |
57 EXPECT_EQ(kUpToDate, GetSecurityStatus(&installer, "11")); | |
58 } | |
OLD | NEW |