Chromium Code Reviews| Index: tests/fake_browser_ppapi/main.cc |
| diff --git a/tests/fake_browser_ppapi/main.cc b/tests/fake_browser_ppapi/main.cc |
| index 0430fad17f00254116d673e8fccc336815d1cd78..1c5620d005b234860ad97d63599f4e446c41861c 100644 |
| --- a/tests/fake_browser_ppapi/main.cc |
| +++ b/tests/fake_browser_ppapi/main.cc |
| @@ -78,15 +78,15 @@ const void* FakeGetBrowserInterface(const char* interface_name) { |
| // The storage allocated by the browser for the window object, etc., are |
| // attributed to the browser's module id. |
| PP_Module BrowserModuleId() { |
| - static void* id; |
| - return reinterpret_cast<PP_Module>(&id); |
| + static PP_Module id = 100; |
|
sehr (please use chromium)
2011/01/12 00:55:10
I presume this number has some significance? Plea
neb
2011/01/13 00:00:43
Done.
|
| + return id; |
| } |
| // The storage allocated by the plugin for its scriptable objects are |
| // attributed to the its module id. |
| PP_Module PluginModuleId() { |
| - static void* id; |
| - return reinterpret_cast<PP_Module>(&id); |
| + static PP_Module id = 1; |
| + return id; |
| } |
| bool ParseArgs(const char* str, |
| @@ -114,11 +114,40 @@ bool ParseArgs(const char* str, |
| for (uint32_t i = 0; i < *argc; ++i) { |
| (*argn)[i] = strdup(argn_vector[i].c_str()); |
| (*argv)[i] = strdup(argv_vector[i].c_str()); |
| - printf("ParseArgs(): arg[%u]: '%s' = '%s'\n", i, (*argn)[i], (*argv)[i]); |
| + DebugPrintf("ParseArgs(): arg[%u]: '%s' = '%s'\n", |
| + i, (*argn)[i], (*argv)[i]); |
| } |
| return true; |
| } |
| +} // namespace |
| + |
| +namespace fake_browser_ppapi { |
| + |
| +PP_Resource TrackResource(Resource* resource) { |
| + PP_Resource resource_id = host->TrackResource(resource); |
| + DebugPrintf("TrackResource: resource_id=%"NACL_PRId32"\n", resource_id); |
| + return resource_id; |
| +} |
| + |
| +Resource* GetResource(PP_Resource resource_id) { |
| + return host->GetResource(resource_id); |
| +} |
| + |
| +PP_Instance TrackInstance(Instance* instance) { |
| + PP_Instance instance_id = host->TrackInstance(instance); |
| + DebugPrintf("TrackInstance: instance_id=%"NACL_PRId32"\n", instance_id); |
| + return instance_id; |
| +} |
| + |
| +Instance* GetInstance(PP_Instance instance_id) { |
| + return host->GetInstance(instance_id); |
| +} |
| + |
| +} // namespace fake_browser_ppapi |
| + |
| +namespace { |
| + |
| // Test instance execution. |
| void TestInstance(PP_Module browser_module_id, |
| const PPP_Instance* instance_interface, |
| @@ -126,24 +155,25 @@ void TestInstance(PP_Module browser_module_id, |
| uint32_t argc, |
| const char** argn, |
| const char** argv) { |
| - printf("TestInstance(): page url %s\n", page_url); |
| + DebugPrintf("TestInstance(): page url %s\n", page_url); |
| // Create an instance and the corresponding id. |
| - fake_browser_ppapi::Instance browser_instance; |
| - PP_Instance instance_id = reinterpret_cast<PP_Instance>(&browser_instance); |
| - |
| + fake_browser_ppapi::Instance* instance = new fake_browser_ppapi::Instance; |
| + PP_Instance instance_id = TrackInstance(instance); |
| // Create a fake window object. |
| FakeWindow window(browser_module_id, instance_id, host, page_url); |
| - browser_instance.set_window(&window); |
| - |
| + instance->set_window(&window); |
| // Create and initialize plugin instance. |
| CHECK(instance_interface->DidCreate(instance_id, argc, argn, argv)); |
| + DebugPrintf("TestInstance(): instance initialized\n"); |
|
sehr (please use chromium)
2011/01/12 00:55:10
Do we need these prints? I think not.
neb
2011/01/13 00:00:43
They sneaked in. Done.
|
| // Test the scriptable object for the instance. |
| PP_Var instance_object = instance_interface->GetInstanceObject(instance_id); |
| + DebugPrintf("TestInstance(): instance object obtained\n"); |
| const PPB_Var_Deprecated* var_interface = |
| reinterpret_cast<const PPB_Var_Deprecated*>( |
| FakeGetBrowserInterface(PPB_VAR_DEPRECATED_INTERFACE)); |
| + DebugPrintf("TestInstance(): PPB_Var_Deprecated interface obtained\n"); |
| TestScriptableObject(instance_object, |
| - browser_instance.GetInterface(), |
| + fake_browser_ppapi::Instance::GetInterface(), |
| var_interface, |
| instance_id, |
| browser_module_id); |
| @@ -151,21 +181,6 @@ void TestInstance(PP_Module browser_module_id, |
| } // namespace |
| -namespace fake_browser_ppapi { |
| - |
| -PP_Resource TrackResource(Resource* resource) { |
| - PP_Resource resource_id = host->TrackResource(resource); |
| - DebugPrintf("TrackResource: resource_id=%"NACL_PRId64"\n", resource_id); |
| - resource->set_resource_id(resource_id); |
| - return resource_id; |
| -} |
| - |
| -Resource* GetResource(PP_Resource resource_id) { |
| - return host->GetResource(resource_id); |
| -} |
| - |
| -} // namespace fake_browser_ppapi |
| - |
| int main(int argc, char** argv) { |
| // Turn off stdout buffering to aid debugging in case of a crash. |
| setvbuf(stdout, NULL, _IONBF, 0); |