OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/common/chrome_paths.h" | 8 #include "chrome/common/chrome_paths.h" |
9 #include "chrome/test/base/v8_unit_test.h" | 9 #include "chrome/test/base/v8_unit_test.h" |
10 #include "grit/renderer_resources.h" | 10 #include "grit/renderer_resources.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/base/layout.h" |
12 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
13 | 14 |
14 static const char kJsonSchema[] = "json_schema.js"; | 15 static const char kJsonSchema[] = "json_schema.js"; |
15 static const char kJsonSchemaTest[] = "json_schema_test.js"; | 16 static const char kJsonSchemaTest[] = "json_schema_test.js"; |
16 | 17 |
17 class JsonSchemaTest : public V8UnitTest { | 18 class JsonSchemaTest : public V8UnitTest { |
18 public: | 19 public: |
19 JsonSchemaTest() {} | 20 JsonSchemaTest() {} |
20 | 21 |
21 virtual void SetUp() { | 22 virtual void SetUp() { |
22 V8UnitTest::SetUp(); | 23 V8UnitTest::SetUp(); |
23 | 24 |
24 // Add the json schema code to the context. | 25 // Add the json schema code to the context. |
25 std::string code = ResourceBundle::GetSharedInstance().GetRawDataResource( | 26 std::string code = ResourceBundle::GetSharedInstance().GetRawDataResource( |
26 IDR_JSON_SCHEMA_JS).as_string(); | 27 IDR_JSON_SCHEMA_JS, ui::SCALE_FACTOR_NONE).as_string(); |
27 | 28 |
28 // json_schema.js expects to have requireNative() defined. | 29 // json_schema.js expects to have requireNative() defined. |
29 ExecuteScriptInContext( | 30 ExecuteScriptInContext( |
30 "function requireNative(id) {" | 31 "function requireNative(id) {" |
31 " return {" | 32 " return {" |
32 " GetChromeHidden: function() { return {}; }," | 33 " GetChromeHidden: function() { return {}; }," |
33 " };" | 34 " };" |
34 "}", | 35 "}", |
35 "test-code"); | 36 "test-code"); |
36 ExecuteScriptInContext(code, kJsonSchema); | 37 ExecuteScriptInContext(code, kJsonSchema); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 TestFunction("testGetAllTypesForSchema"); | 99 TestFunction("testGetAllTypesForSchema"); |
99 } | 100 } |
100 | 101 |
101 TEST_F(JsonSchemaTest, TestIsValidSchemaType) { | 102 TEST_F(JsonSchemaTest, TestIsValidSchemaType) { |
102 TestFunction("testIsValidSchemaType"); | 103 TestFunction("testIsValidSchemaType"); |
103 } | 104 } |
104 | 105 |
105 TEST_F(JsonSchemaTest, TestCheckSchemaOverlap) { | 106 TEST_F(JsonSchemaTest, TestCheckSchemaOverlap) { |
106 TestFunction("testCheckSchemaOverlap"); | 107 TestFunction("testCheckSchemaOverlap"); |
107 } | 108 } |
OLD | NEW |