blob: d03606c3f94a767baf5393b5e7fafc065cae0208 [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]61fcb162012-09-04 23:08:545#include "webkit/plugins/npapi/plugin_utils.h"
[email protected]0a8b1e22010-07-02 09:31:116
7#include <string>
8#include <vector>
9
[email protected]3b63f8f42011-03-28 01:54:1510#include "base/memory/scoped_ptr.h"
[email protected]be1ce6a72010-08-03 14:35:2211#include "base/utf_string_conversions.h"
[email protected]0a8b1e22010-07-02 09:31:1112#include "base/version.h"
13#include "testing/gtest/include/gtest/gtest.h"
[email protected]191eb3f72010-12-21 06:27:5014
15namespace webkit {
16namespace npapi {
[email protected]0a8b1e22010-07-02 09:31:1117
[email protected]61fcb162012-09-04 23:08:5418TEST(PluginUtilsTest, VersionExtraction) {
[email protected]0a8b1e22010-07-02 09:31:1119 // Some real-world plugin versions (spaces, commata, parentheses, 'r', oh my)
20 const char* versions[][2] = {
21 { "7.6.6 (1671)", "7.6.6.1671" }, // Quicktime
22 { "2, 0, 0, 254", "2.0.0.254" }, // DivX
23 { "3, 0, 0, 0", "3.0.0.0" }, // Picasa
24 { "1, 0, 0, 1", "1.0.0.1" }, // Earth
25 { "10,0,45,2", "10.0.45.2" }, // Flash
[email protected]960eec62011-01-11 08:39:4926 { "10.1 r102", "10.1.102"}, // Flash
[email protected]c2a1dbe2011-02-23 10:14:2427 { "10.3 d180", "10.3.180" }, // Flash (Debug)
28 { "11.5.7r609", "11.5.7.609"}, // Shockwave
[email protected]960eec62011-01-11 08:39:4929 { "1.6.0_22", "1.6.0.22"}, // Java
[email protected]bf7bb5b42012-08-13 15:07:3830 { "1.07.00_0005", "1.7.0.5"}, // Java with leading zeros
31 { "1..0", "1.0.0" } // Empty version component
[email protected]0a8b1e22010-07-02 09:31:1132 };
33
34 for (size_t i = 0; i < arraysize(versions); i++) {
[email protected]12126d372012-07-11 18:40:5335 Version version;
[email protected]61fcb162012-09-04 23:08:5436 CreateVersionFromString(ASCIIToUTF16(versions[i][0]), &version);
[email protected]bf7bb5b42012-08-13 15:07:3837
38 ASSERT_TRUE(version.IsValid());
[email protected]12126d372012-07-11 18:40:5339 EXPECT_EQ(versions[i][1], version.GetString());
[email protected]0a8b1e22010-07-02 09:31:1140 }
41}
[email protected]fda165782010-09-16 11:23:1742
[email protected]191eb3f72010-12-21 06:27:5043} // namespace npapi
44} // namespace webkit