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

Side by Side Diff: chrome/test/base/module_system_test.cc

Issue 10387010: Select theme resources from ResourceBundle at requested scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with master. Created 8 years, 7 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
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
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() {
112 EXPECT_FALSE(try_catch_.HasCaught()); 114 EXPECT_FALSE(try_catch_.HasCaught());
113 // All tests must assert at least once unless otherwise specified. 115 // All tests must assert at least once unless otherwise specified.
114 EXPECT_EQ(should_assertions_be_made_, 116 EXPECT_EQ(should_assertions_be_made_,
115 assert_natives_->assertion_made()); 117 assert_natives_->assertion_made());
116 EXPECT_FALSE(assert_natives_->failed()); 118 EXPECT_FALSE(assert_natives_->failed());
117 } 119 }
118 120
119 void ModuleSystemTest::ExpectNoAssertionsMade() { 121 void ModuleSystemTest::ExpectNoAssertionsMade() {
120 should_assertions_be_made_ = false; 122 should_assertions_be_made_ = false;
121 } 123 }
122 124
123 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) { 125 v8::Handle<v8::Object> ModuleSystemTest::CreateGlobal(const std::string& name) {
124 v8::HandleScope handle_scope; 126 v8::HandleScope handle_scope;
125 v8::Handle<v8::Object> object = v8::Object::New(); 127 v8::Handle<v8::Object> object = v8::Object::New();
126 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()), 128 v8::Context::GetCurrent()->Global()->Set(v8::String::New(name.c_str()),
127 object); 129 object);
128 return handle_scope.Close(object); 130 return handle_scope.Close(object);
129 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698