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 "chrome/test/base/module_system_test.h" | 5 #include "chrome/test/base/module_system_test.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
10 #include "chrome/renderer/native_handler.h" | 10 #include "chrome/renderer/native_handler.h" |
| 11 #include "ui/base/layout.h" |
11 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
12 | 13 |
13 #include <map> | 14 #include <map> |
14 #include <string> | 15 #include <string> |
15 | 16 |
16 // Native JS functions for doing asserts. | 17 // Native JS functions for doing asserts. |
17 class AssertNatives : public NativeHandler { | 18 class AssertNatives : public NativeHandler { |
18 public: | 19 public: |
19 AssertNatives() | 20 AssertNatives() |
20 : assertion_made_(false), | 21 : assertion_made_(false), |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 92 } |
92 | 93 |
93 void ModuleSystemTest::RegisterModule(const std::string& name, | 94 void ModuleSystemTest::RegisterModule(const std::string& name, |
94 const std::string& code) { | 95 const std::string& code) { |
95 source_map_->RegisterModule(name, code); | 96 source_map_->RegisterModule(name, code); |
96 } | 97 } |
97 | 98 |
98 void ModuleSystemTest::RegisterModule(const std::string& name, | 99 void ModuleSystemTest::RegisterModule(const std::string& name, |
99 int resource_id) { | 100 int resource_id) { |
100 const std::string& code = ResourceBundle::GetSharedInstance(). | 101 const std::string& code = ResourceBundle::GetSharedInstance(). |
101 GetRawDataResource(resource_id).as_string(); | 102 GetRawDataResource(resource_id, |
| 103 ui::SCALE_FACTOR_NONE).as_string(); |
102 source_map_->RegisterModule(name, code); | 104 source_map_->RegisterModule(name, code); |
103 } | 105 } |
104 | 106 |
105 void ModuleSystemTest::OverrideNativeHandler(const std::string& name, | 107 void ModuleSystemTest::OverrideNativeHandler(const std::string& name, |
106 const std::string& code) { | 108 const std::string& code) { |
107 RegisterModule(name, code); | 109 RegisterModule(name, code); |
108 module_system_->OverrideNativeHandler(name); | 110 module_system_->OverrideNativeHandler(name); |
109 } | 111 } |
110 | 112 |
111 void ModuleSystemTest::TearDown() { | 113 void ModuleSystemTest::TearDown() { |
(...skipping 10 matching lines...) Expand all Loading... |
122 should_assertions_be_made_ = false; | 124 should_assertions_be_made_ = false; |
123 } | 125 } |
124 | 126 |
125 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { | 127 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { |
126 v8::HandleScope handle_scope; | 128 v8::HandleScope handle_scope; |
127 v8::Handle<v8::Object> object = v8::Object::New(); | 129 v8::Handle<v8::Object> object = v8::Object::New(); |
128 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), | 130 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), |
129 object); | 131 object); |
130 return handle_scope.Close(object); | 132 return handle_scope.Close(object); |
131 } | 133 } |
OLD | NEW |