Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Side by Side Diff: chrome/common/extensions/api/extension_api_feature_unittest.cc

Issue 10025007: Convert tabs, windows, and extension APIs to feature system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #include "chrome/common/extensions/api/extension_api_feature.h"
6
7 #include "base/file_path.h"
8 #include "base/file_util.h"
9 #include "base/json/json_reader.h"
10 #include "base/path_service.h"
11 #include "chrome/common/chrome_paths.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace extensions {
15
16 TEST(ExtensionAPIFeature, Basics) {
17 FilePath value_path;
18 PathService::Get(chrome::DIR_TEST_DATA, &value_path);
19 value_path = value_path.AppendASCII("extensions")
20 .AppendASCII("extension_api_feature_unittest")
21 .AppendASCII("test1.json");
22
23 std::string value_str;
24 ASSERT_TRUE(file_util::ReadFileToString(value_path, &value_str));
25
26 scoped_ptr<DictionaryValue> value;
27 {
28 const bool kAllowTrailingComma = false;
29 Value* temp = base::JSONReader::Read(value_str, kAllowTrailingComma);
30 CHECK(temp);
31 CHECK(temp->IsType(Value::TYPE_DICTIONARY));
32 value.reset(static_cast<DictionaryValue*>(temp));
33 }
34
35 ExtensionAPIFeature feature;
36 feature.set_name("parent");
37 feature.Parse(value.get());
38
39 EXPECT_EQ(1u, feature.extension_types()->size());
40 EXPECT_EQ(1u, feature.extension_types()->count(Extension::TYPE_EXTENSION));
41 EXPECT_EQ(1u, feature.contexts()->size());
42 EXPECT_EQ(1u, feature.contexts()->count(Feature::BLESSED_EXTENSION_CONTEXT));
43
44 ExtensionAPIFeature* child_function = static_cast<ExtensionAPIFeature*>(
45 feature.GetChild("unknown"));
46 EXPECT_FALSE(child_function);
47 child_function = static_cast<ExtensionAPIFeature*>(
48 feature.GetChild("function"));
49 EXPECT_TRUE(child_function);
50 EXPECT_EQ(1u, child_function->dependencies()->size());
51 EXPECT_EQ(1u, child_function->dependencies()->count("api:parent"));
52 EXPECT_EQ(1u, child_function->extension_types()->size());
53 EXPECT_EQ(1u, child_function->extension_types()->count(
54 Extension::TYPE_PACKAGED_APP));
55
56 child_function = static_cast<ExtensionAPIFeature*>(feature.GetChild("event"));
57 EXPECT_TRUE(child_function);
58 EXPECT_EQ(2u, child_function->dependencies()->size());
59 EXPECT_EQ(1u, child_function->dependencies()->count("api:parent"));
60 EXPECT_EQ(1u, child_function->dependencies()->count("permission:whatever"));
61 EXPECT_EQ(0u, child_function->extension_types()->size());
62 EXPECT_EQ(1u, child_function->contexts()->size());
63 EXPECT_EQ(1u, child_function->contexts()->count(
64 Feature::UNBLESSED_EXTENSION_CONTEXT));
65 }
66
67 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/extension_api_feature.cc ('k') | chrome/common/extensions/api/extension_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698