Rename desktop_cursor_loader_updater_aurax11.
[chromium-blink-merge.git] / chrome / browser / plugins / plugin_finder_unittest.cc
blob5afe3d1ae90e5ddd66c89005e7006df317f7fe10
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_finder.h"
7 #include "base/values.h"
8 #include "chrome/browser/plugins/plugin_metadata.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 using base::DictionaryValue;
12 using base::ListValue;
14 TEST(PluginFinderTest, JsonSyntax) {
15 scoped_ptr<DictionaryValue> plugin_list(
16 PluginFinder::LoadBuiltInPluginList());
17 ASSERT_TRUE(plugin_list.get());
18 scoped_ptr<base::Value> version;
19 ASSERT_TRUE(plugin_list->Remove("x-version", &version));
20 EXPECT_EQ(base::Value::TYPE_INTEGER, version->GetType());
22 for (DictionaryValue::Iterator plugin_it(*plugin_list);
23 !plugin_it.IsAtEnd(); plugin_it.Advance()) {
24 const DictionaryValue* plugin = NULL;
25 ASSERT_TRUE(plugin_it.value().GetAsDictionary(&plugin));
26 std::string dummy_str;
27 bool dummy_bool;
28 if (plugin->HasKey("lang"))
29 EXPECT_TRUE(plugin->GetString("lang", &dummy_str));
30 if (plugin->HasKey("url"))
31 EXPECT_TRUE(plugin->GetString("url", &dummy_str));
32 EXPECT_TRUE(plugin->GetString("name", &dummy_str));
33 if (plugin->HasKey("help_url"))
34 EXPECT_TRUE(plugin->GetString("help_url", &dummy_str));
35 if (plugin->HasKey("displayurl"))
36 EXPECT_TRUE(plugin->GetBoolean("displayurl", &dummy_bool));
37 if (plugin->HasKey("requires_authorization"))
38 EXPECT_TRUE(plugin->GetBoolean("requires_authorization", &dummy_bool));
39 const ListValue* mime_types = NULL;
40 if (plugin->GetList("mime_types", &mime_types)) {
41 for (ListValue::const_iterator mime_type_it = mime_types->begin();
42 mime_type_it != mime_types->end(); ++mime_type_it) {
43 EXPECT_TRUE((*mime_type_it)->GetAsString(&dummy_str));
47 const ListValue* matching_mime_types = NULL;
48 if (plugin->GetList("matching_mime_types", &matching_mime_types)) {
49 for (ListValue::const_iterator it = matching_mime_types->begin();
50 it != matching_mime_types->end(); ++it) {
51 EXPECT_TRUE((*it)->GetAsString(&dummy_str));
55 const ListValue* versions = NULL;
56 if (!plugin->GetList("versions", &versions))
57 continue;
59 for (ListValue::const_iterator it = versions->begin();
60 it != versions->end(); ++it) {
61 DictionaryValue* version_dict = NULL;
62 ASSERT_TRUE((*it)->GetAsDictionary(&version_dict));
63 EXPECT_TRUE(version_dict->GetString("version", &dummy_str));
64 std::string status_str;
65 EXPECT_TRUE(version_dict->GetString("status", &status_str));
66 PluginMetadata::SecurityStatus status =
67 PluginMetadata::SECURITY_STATUS_UP_TO_DATE;
68 EXPECT_TRUE(PluginMetadata::ParseSecurityStatus(status_str, &status))
69 << "Invalid security status \"" << status_str << "\"";