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

Unified Diff: chrome/test/base/module_system_test.h

Issue 359413004: Add support for using AMD modules from extensions modules. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cross-context tests Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/module_system_test.h
diff --git a/chrome/test/base/module_system_test.h b/chrome/test/base/module_system_test.h
index 8402d57b39e2e74921ffd3a11797cca91045dd74..529568fd2f6bdec9f72e3591f92ba200300fc7fb 100644
--- a/chrome/test/base/module_system_test.h
+++ b/chrome/test/base/module_system_test.h
@@ -8,9 +8,60 @@
#include "chrome/renderer/extensions/chrome_v8_context.h"
#include "extensions/renderer/module_system.h"
#include "extensions/renderer/scoped_persistent.h"
+#include "gin/public/context_holder.h"
+#include "gin/public/isolate_holder.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "v8/include/v8.h"
+class ModuleSystemTestEnvironment {
+ public:
+ class AssertNatives;
+ class StringSourceMap;
+
+ explicit ModuleSystemTestEnvironment(gin::IsolateHolder* isolate_holder);
+ ~ModuleSystemTestEnvironment();
+
+ // Register a named JS module in the module system.
+ void RegisterModule(const std::string& name, const std::string& code);
+
+ // Register a named JS module with source retrieved from a ResourceBundle.
+ void RegisterModule(const std::string& name, int resource_id);
+
+ // Register a named JS module in the module system and tell the module system
+ // to use it to handle any requireNative() calls for native modules with that
+ // name.
+ void OverrideNativeHandler(const std::string& name, const std::string& code);
+
+ // Registers |file_name| from chrome/test/data/extensions as a module name
+ // |module_name|.
not at google - send to devlin 2014/07/07 23:18:50 heh, we should use this more. those embedded strin
+ void RegisterTestFile(const std::string& module_name,
+ const std::string& file_name);
+
+ // Create an empty object in the global scope with name |name|.
+ v8::Handle<v8::Object> CreateGlobal(const std::string& name);
+
+ void DeleteContextHolder();
not at google - send to devlin 2014/07/07 23:18:50 I don't know what ContextHolder is. would it be ac
Sam McNally 2014/07/08 00:07:04 Done.
+
+ void DeleteModuleSystem();
+
+ extensions::ModuleSystem* module_system() {
+ return context_->module_system();
+ }
+
+ extensions::ChromeV8Context* context() { return context_.get(); }
+
+ AssertNatives* assert_natives() { return assert_natives_; }
+
+ private:
+ scoped_ptr<gin::ContextHolder> context_holder_;
+ v8::HandleScope handle_scope_;
+ scoped_ptr<extensions::ChromeV8Context> context_;
+ AssertNatives* assert_natives_;
+ scoped_ptr<StringSourceMap> source_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(ModuleSystemTestEnvironment);
+};
+
// Test fixture for testing JS that makes use of the module system.
//
// Typically tests will look like:
@@ -33,36 +84,16 @@ class ModuleSystemTest : public testing::Test {
virtual void TearDown() OVERRIDE;
protected:
- // Register a named JS module in the module system.
- void RegisterModule(const std::string& name, const std::string& code);
-
- // Register a named JS module with source retrieved from a ResourceBundle.
- void RegisterModule(const std::string& name, int resource_id);
-
- // Register a named JS module in the module system and tell the module system
- // to use it to handle any requireNative() calls for native modules with that
- // name.
- void OverrideNativeHandler(const std::string& name, const std::string& code);
-
- // Registers |file_name| from chrome/test/data/extensions as a module name
- // |module_name|.
- void RegisterTestFile(const std::string& module_name,
- const std::string& file_name);
-
// Make the test fail if any asserts are called. By default a test will fail
// if no asserts are called.
void ExpectNoAssertionsMade();
- // Create an empty object in the global scope with name |name|.
- v8::Handle<v8::Object> CreateGlobal(const std::string& name);
+ // Runs promises that have been resolved. Resolved promises will not run
+ // until this is called.
+ void RunResolvedPromises();
- v8::Isolate* isolate_;
- v8::HandleScope handle_scope_;
- scoped_ptr<extensions::ChromeV8Context> context_;
- class AssertNatives;
- AssertNatives* assert_natives_;
- class StringSourceMap;
- scoped_ptr<StringSourceMap> source_map_;
+ gin::IsolateHolder isolate_holder_;
not at google - send to devlin 2014/07/07 23:18:50 could you expose a CreateEnvironment() and make th
Sam McNally 2014/07/08 00:07:04 Done.
+ ModuleSystemTestEnvironment env_;
not at google - send to devlin 2014/07/07 23:18:50 it would be nicer if all of these were private, an
Sam McNally 2014/07/08 00:07:04 Done.
bool should_assertions_be_made_;
private:

Powered by Google App Engine
This is Rietveld 408576698