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