blob: a204f2862df9c6c01a79c5ed88399655fc5d4696 [file] [log] [blame]
[email protected]4dd01a042012-03-26 18:03:261// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]0a8b1e22010-07-02 09:31:112// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]d7bd3e52013-07-21 04:29:205#include "content/public/common/webplugininfo.h"
[email protected]0a8b1e22010-07-02 09:31:116
avia9aa7a82015-12-25 03:06:317#include <stddef.h>
8
dcheng4ac58c7a2016-04-09 04:51:489#include <memory>
[email protected]0a8b1e22010-07-02 09:31:1110#include <string>
11#include <vector>
12
[email protected]906265872013-06-07 22:40:4513#include "base/strings/utf_string_conversions.h"
[email protected]0a8b1e22010-07-02 09:31:1114#include "base/version.h"
15#include "testing/gtest/include/gtest/gtest.h"
[email protected]191eb3f72010-12-21 06:27:5016
[email protected]d7bd3e52013-07-21 04:29:2017namespace content {
[email protected]0a8b1e22010-07-02 09:31:1118
[email protected]61fcb162012-09-04 23:08:5419TEST(PluginUtilsTest, VersionExtraction) {
[email protected]0a8b1e22010-07-02 09:31:1120 // 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]960eec62011-01-11 08:39:4927 { "10.1 r102", "10.1.102"}, // Flash
[email protected]c2a1dbe2011-02-23 10:14:2428 { "10.3 d180", "10.3.180" }, // Flash (Debug)
29 { "11.5.7r609", "11.5.7.609"}, // Shockwave
[email protected]960eec62011-01-11 08:39:4930 { "1.6.0_22", "1.6.0.22"}, // Java
[email protected]bf7bb5b42012-08-13 15:07:3831 { "1.07.00_0005", "1.7.0.5"}, // Java with leading zeros
32 { "1..0", "1.0.0" } // Empty version component
[email protected]0a8b1e22010-07-02 09:31:1133 };
34
Daniel Chengad44af2f2022-02-26 18:07:5435 for (size_t i = 0; i < std::size(versions); i++) {
pwnall622e2f72016-08-22 19:38:2836 base::Version version;
[email protected]9a60ccb2013-07-19 22:23:3637 WebPluginInfo::CreateVersionFromString(
[email protected]32956122013-12-25 07:29:2438 base::ASCIIToUTF16(versions[i][0]), &version);
[email protected]bf7bb5b42012-08-13 15:07:3839
40 ASSERT_TRUE(version.IsValid());
[email protected]12126d372012-07-11 18:40:5341 EXPECT_EQ(versions[i][1], version.GetString());
[email protected]0a8b1e22010-07-02 09:31:1142 }
43}
[email protected]fda165782010-09-16 11:23:1744
[email protected]d7bd3e52013-07-21 04:29:2045} // namespace content