From fb32c4a83ba648d8522160737187e7d2b2845c3f Mon Sep 17 00:00:00 2001 From: "gears.daemon" Date: Wed, 30 Jan 2008 03:00:52 +0000 Subject: [PATCH] [Author: aa] NOTE: I sent this CL out for review once before, but accidentally deleted it before it got reviewed. === Rollback part of CL 6139360. That change implemented ModuleWrapper and JsCallContext for IE and made the GearsTest module use it. The implementation of ModuleWrapper is incomplete though and getting in the way of people using GearsTest for other things. This change leaves ModuleWrapper and JsCallContext checked in, but not hooked up to anything. It also reverts GearsTest to use COM and XPCOM. PRESUBMIT=passed R=marli CC=google-gears-eng@googlegroups.com APPROVED=oshlack DELTA=121 (13 added, 98 deleted, 10 changed) OCL=6342431 SCL=6344007 git-svn-id: https://google-gears.googlecode.com/svn/trunk@786 fe895e04-df30-0410-9975-d76d301b4276 --- gears/cctests/test.cc | 92 +++++++-------------------------------------- gears/cctests/test_ie.h | 12 ++---- gears/cctests/test_ie.idl | 5 +-- gears/factory/ie/factory.cc | 20 ++-------- 4 files changed, 22 insertions(+), 107 deletions(-) diff --git a/gears/cctests/test.cc b/gears/cctests/test.cc index 034bfd6..a981534 100644 --- a/gears/cctests/test.cc +++ b/gears/cctests/test.cc @@ -38,12 +38,10 @@ #include "gears/cctests/test_ff.h" #elif BROWSER_IE #include "gears/base/ie/activex_utils.h" -#include "gears/base/ie/module_wrapper.h" #include "gears/cctests/test_ie.h" #endif #include "gears/base/common/name_value_table_test.h" -#include "gears/base/common/js_types.h" #include "gears/base/common/permissions_db.h" #include "gears/base/common/permissions_db_test.h" #include "gears/base/common/sqlite_wrapper_test.h" @@ -58,6 +56,16 @@ #include "gears/localserver/common/resource_store.h" #include "gears/third_party/scoped_ptr/scoped_ptr.h" +// Constants for returning a boolean value - hopefully there should be a +// standard way to do this one day. +#if BROWSER_FF + const PRBool BROWSER_TRUE = PR_TRUE; + const PRBool BROWSER_FALSE = PR_FALSE; +#elif BROWSER_IE + const VARIANT_BOOL BROWSER_TRUE = VARIANT_TRUE; + const VARIANT_BOOL BROWSER_FALSE = VARIANT_FALSE; +#endif + #if BROWSER_FF // Boilerplate. == NS_IMPL_ISUPPORTS + ..._MAP_ENTRY_EXTERNAL_DOM_CLASSINFO NS_IMPL_ADDREF(GearsTest) @@ -96,87 +104,13 @@ bool TestBlobBuilder(); #if BROWSER_FF NS_IMETHODIMP GearsTest::RunTests(PRBool *retval) { - *retval = RunTestsImpl() ? PR_TRUE : PR_FALSE; - RETURN_NORMAL(); -} #elif BROWSER_IE -STDMETHODIMP GearsTest::RunTests() { - JsCallContext *js_call_context = ModuleWrapper::PeekJsCallContext(); - bool result = RunTestsImpl(); - js_call_context->SetReturnValue(JSPARAM_BOOL, &result); - RETURN_NORMAL(); -} - -// Following methods only implemented for IE so far -STDMETHODIMP GearsTest::testParamTypes() { - JsCallContext *js_call_context = ModuleWrapper::PeekJsCallContext(); - - bool bool_param; - int int_param; - double double_param; - JsObject object_param; - std::string16 string_param; - - JsArgument argv[] = { - { JSPARAM_REQUIRED, JSPARAM_BOOL, &bool_param }, - { JSPARAM_REQUIRED, JSPARAM_INT, &int_param }, - { JSPARAM_REQUIRED, JSPARAM_DOUBLE, &double_param }, - { JSPARAM_REQUIRED, JSPARAM_OBJECT, &object_param }, - { JSPARAM_REQUIRED, JSPARAM_STRING16, &string_param } - }; - int argc = js_call_context->GetArguments(ARRAYSIZE(argv), argv); - if (argc < ARRAYSIZE(argv)) RETURN_NORMAL(); - - if (bool_param != true) { - js_call_context->SetException( - STRING16(L"Expected first parameter to be true.")); - RETURN_NORMAL(); - } - - if (int_param != 42) { - js_call_context->SetException( - STRING16(L"Expected second parameter to be 42.")); - RETURN_NORMAL(); - } - - if (double_param != 88.8) { - js_call_context->SetException( - STRING16(L"Expected third parameter to be 88.8")); - RETURN_NORMAL(); - } - - if (string_param != STRING16(L"foo")) { - js_call_context->SetException( - STRING16(L"Expected fifth parameter to be 'foo'.")); - RETURN_NORMAL(); - } - - RETURN_NORMAL(); -} - -STDMETHODIMP GearsTest::put_testPropertyInt(VARIANT *val) { - JsCallContext *js_call_context = ModuleWrapper::PeekJsCallContext(); - - int int_param; - JsArgument argv[] = { - { JSPARAM_REQUIRED, JSPARAM_INT, &int_param } - }; - int argc = ARRAYSIZE(argv); - if (js_call_context->GetArguments(argc, argv) < argc) - RETURN_NORMAL(); - - test_property_value_ = int_param; - RETURN_NORMAL(); -} - -STDMETHODIMP GearsTest::get_testPropertyInt(VARIANT *val) { - JsCallContext *js_call_context = ModuleWrapper::PeekJsCallContext(); - js_call_context->SetReturnValue(JSPARAM_INT, &test_property_value_); +STDMETHODIMP GearsTest::RunTests(VARIANT_BOOL *retval) { +#endif + *retval = RunTestsImpl() ? BROWSER_TRUE : BROWSER_FALSE; RETURN_NORMAL(); } -#endif - bool GearsTest::RunTestsImpl() { // We need permissions to use the localserver. SecurityOrigin cc_tests_origin; diff --git a/gears/cctests/test_ie.h b/gears/cctests/test_ie.h index 5b4d554..5785b4c 100644 --- a/gears/cctests/test_ie.h +++ b/gears/cctests/test_ie.h @@ -49,21 +49,17 @@ class GearsTest // End boilerplate code. Begin interface. // need a default constructor to instance objects from the Factory - GearsTest() : test_property_value_(0) {} + GearsTest() {} ~GearsTest() {} - STDMETHOD(RunTests)(); - STDMETHOD(testParamTypes)(); - STDMETHOD(put_testPropertyInt)(VARIANT *val); - STDMETHOD(get_testPropertyInt)(VARIANT *val); + // JS function is runTests(). + STDMETHOD(RunTests)( + /* [retval][out] */ VARIANT_BOOL *retval); - private: // Generic Cross-Browser function to actually run the tests. bool RunTestsImpl(); - int test_property_value_; - DISALLOW_EVIL_CONSTRUCTORS(GearsTest); }; diff --git a/gears/cctests/test_ie.idl b/gears/cctests/test_ie.idl index 30232b8..5c6e8da 100644 --- a/gears/cctests/test_ie.idl +++ b/gears/cctests/test_ie.idl @@ -40,10 +40,7 @@ import "ocidl.idl"; pointer_default(unique) ] interface GearsTestInterface : IDispatch { - HRESULT RunTests(); - HRESULT testParamTypes(); - [propput] HRESULT testPropertyInt([in] VARIANT *val); - [propget] HRESULT testPropertyInt([out, retval] VARIANT *val); + HRESULT RunTests([out, retval] VARIANT_BOOL *can); }; #endif DEBUG diff --git a/gears/factory/ie/factory.cc b/gears/factory/ie/factory.cc index b5a4eda..20457c7 100755 --- a/gears/factory/ie/factory.cc +++ b/gears/factory/ie/factory.cc @@ -29,7 +29,6 @@ #include "gears/base/ie/activex_utils.h" #include "gears/base/ie/atl_headers.h" #include "gears/base/ie/detect_version_collision.h" -#include "gears/base/ie/module_wrapper.h" #include "gears/console/ie/console_ie.h" #include "gears/database/ie/database.h" #include "gears/desktop/desktop_ie.h" @@ -138,21 +137,10 @@ STDMETHODIMP GearsFactory::create(const BSTR object_name_bstr_in, idispatch = obj; } else if (object_name == STRING16(L"beta.test")) { #ifdef DEBUG - // TODO(aa): Initialization of the wrapper can be factored out when more - // modules use ModuleWrapper. - CComObject *wrapper; - hr = CComObject::CreateInstance(&wrapper); - idispatch = wrapper; - - // TODO(aa): Simplify this when Gears objects in IE are no longer COM - // objects. - CComObject *gears_object; - hr = CComObject::CreateInstance(&gears_object); - base_class = gears_object; - - IDispatch *gears_object_dispatch; - hr = gears_object->QueryInterface(&gears_object_dispatch); - wrapper->Init(gears_object_dispatch); + CComObject *obj; + hr = CComObject::CreateInstance(&obj); + base_class = obj; + idispatch = obj; #else RETURN_EXCEPTION(STRING16(L"Object is only available in debug build.")); #endif -- 2.11.4.GIT