[email protected] | 4dd01a04 | 2012-03-26 18:03:26 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 0a8b1e2 | 2010-07-02 09:31:11 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | d7bd3e5 | 2013-07-21 04:29:20 | [diff] [blame] | 5 | #include "content/public/common/webplugininfo.h" |
[email protected] | 0a8b1e2 | 2010-07-02 09:31:11 | [diff] [blame] | 6 | |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 7 | #include <stddef.h> |
| 8 | |
dcheng | 4ac58c7a | 2016-04-09 04:51:48 | [diff] [blame] | 9 | #include <memory> |
[email protected] | 0a8b1e2 | 2010-07-02 09:31:11 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
[email protected] | 90626587 | 2013-06-07 22:40:45 | [diff] [blame] | 13 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 0a8b1e2 | 2010-07-02 09:31:11 | [diff] [blame] | 14 | #include "base/version.h" |
| 15 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 16 | |
[email protected] | d7bd3e5 | 2013-07-21 04:29:20 | [diff] [blame] | 17 | namespace content { |
[email protected] | 0a8b1e2 | 2010-07-02 09:31:11 | [diff] [blame] | 18 | |
[email protected] | 61fcb16 | 2012-09-04 23:08:54 | [diff] [blame] | 19 | TEST(PluginUtilsTest, VersionExtraction) { |
[email protected] | 0a8b1e2 | 2010-07-02 09:31:11 | [diff] [blame] | 20 | // Some real-world plugin versions (spaces, commata, parentheses, 'r', oh my) |
| 21 | const char* versions[][2] = { |
| 22 | { "7.6.6 (1671)", "7.6.6.1671" }, // Quicktime |
| 23 | { "2, 0, 0, 254", "2.0.0.254" }, // DivX |
| 24 | { "3, 0, 0, 0", "3.0.0.0" }, // Picasa |
| 25 | { "1, 0, 0, 1", "1.0.0.1" }, // Earth |
| 26 | { "10,0,45,2", "10.0.45.2" }, // Flash |
[email protected] | 960eec6 | 2011-01-11 08:39:49 | [diff] [blame] | 27 | { "10.1 r102", "10.1.102"}, // Flash |
[email protected] | c2a1dbe | 2011-02-23 10:14:24 | [diff] [blame] | 28 | { "10.3 d180", "10.3.180" }, // Flash (Debug) |
| 29 | { "11.5.7r609", "11.5.7.609"}, // Shockwave |
[email protected] | 960eec6 | 2011-01-11 08:39:49 | [diff] [blame] | 30 | { "1.6.0_22", "1.6.0.22"}, // Java |
[email protected] | bf7bb5b4 | 2012-08-13 15:07:38 | [diff] [blame] | 31 | { "1.07.00_0005", "1.7.0.5"}, // Java with leading zeros |
| 32 | { "1..0", "1.0.0" } // Empty version component |
[email protected] | 0a8b1e2 | 2010-07-02 09:31:11 | [diff] [blame] | 33 | }; |
| 34 | |
Daniel Cheng | ad44af2f | 2022-02-26 18:07:54 | [diff] [blame] | 35 | for (size_t i = 0; i < std::size(versions); i++) { |
pwnall | 622e2f7 | 2016-08-22 19:38:28 | [diff] [blame] | 36 | base::Version version; |
[email protected] | 9a60ccb | 2013-07-19 22:23:36 | [diff] [blame] | 37 | WebPluginInfo::CreateVersionFromString( |
[email protected] | 3295612 | 2013-12-25 07:29:24 | [diff] [blame] | 38 | base::ASCIIToUTF16(versions[i][0]), &version); |
[email protected] | bf7bb5b4 | 2012-08-13 15:07:38 | [diff] [blame] | 39 | |
| 40 | ASSERT_TRUE(version.IsValid()); |
[email protected] | 12126d37 | 2012-07-11 18:40:53 | [diff] [blame] | 41 | EXPECT_EQ(versions[i][1], version.GetString()); |
[email protected] | 0a8b1e2 | 2010-07-02 09:31:11 | [diff] [blame] | 42 | } |
| 43 | } |
[email protected] | fda16578 | 2010-09-16 11:23:17 | [diff] [blame] | 44 | |
[email protected] | d7bd3e5 | 2013-07-21 04:29:20 | [diff] [blame] | 45 | } // namespace content |