Chromium Code Reviews| Index: chrome/test/data/nacl/manifest_file/irt_manifest_file_fail_test.cc |
| diff --git a/chrome/test/data/nacl/manifest_file/irt_manifest_file_fail_test.cc b/chrome/test/data/nacl/manifest_file/irt_manifest_file_fail_test.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..68d9bfdfbab6021ca8910190978bf67b245e65c0 |
| --- /dev/null |
| +++ b/chrome/test/data/nacl/manifest_file/irt_manifest_file_fail_test.cc |
| @@ -0,0 +1,81 @@ |
| +/* |
|
Mark Seaborn
2014/05/28 16:30:34
Could you possibly merge this into the existing te
hidehiko
2014/05/29 06:58:39
Ok, I rewrote most of code. How about this?
|
| + * Copyright 2014 The Chromium Authors. All rights reserved. |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +// |
| +// Test for resource open before PPAPI initialization. |
| +// |
| + |
| +#include <stdio.h> |
| +#include <string.h> |
| + |
| +#include <sstream> |
| +#include <string> |
| + |
| +#include "native_client/src/untrusted/irt/irt.h" |
| +#include "native_client/src/untrusted/nacl/nacl_irt.h" |
| + |
| +#include "ppapi/cpp/instance.h" |
| +#include "ppapi/cpp/module.h" |
| +#include "ppapi/cpp/var.h" |
| +#include "ppapi/native_client/src/shared/ppapi_proxy/ppruntime.h" |
| + |
| +int error = 0; |
| + |
| +void load_manifest(TYPE_nacl_irt_query *query_func) { |
| + struct nacl_irt_resource_open nacl_irt_resource_open; |
| + if (sizeof(nacl_irt_resource_open) != |
| + (*query_func)( |
| + NACL_IRT_RESOURCE_OPEN_v0_1, |
| + &nacl_irt_resource_open, |
| + sizeof(nacl_irt_resource_open))) { |
| + printf("irt_resource_open is not found.\n"); |
| + return; |
| + } |
| + |
| + int desc; |
| + error = nacl_irt_resource_open.open_resource("non-exist-file", &desc); |
|
Mark Seaborn
2014/05/28 16:30:34
Nit: "non-existent-file" perhaps?
hidehiko
2014/05/29 06:58:39
Done, in irt_manifest_file_test.cc.
|
| + if (error == 0) { |
| + printf("Unexpectedly opened the file.\n"); |
| + return; |
| + } |
| +} |
| + |
| +class TestInstance : public pp::Instance { |
| + public: |
| + explicit TestInstance(PP_Instance instance) : pp::Instance(instance) {} |
| + virtual ~TestInstance() {} |
| + virtual void HandleMessage(const pp::Var& var_message) { |
| + if (!var_message.is_string()) { |
| + return; |
| + } |
| + if (var_message.AsString() != "hello") { |
| + return; |
| + } |
| + pp::Var reply = pp::Var(error); |
| + PostMessage(reply); |
| + } |
| +}; |
| + |
| +class TestModule : public pp::Module { |
| + public: |
| + TestModule() : pp::Module() {} |
| + virtual ~TestModule() {} |
| + |
| + virtual pp::Instance* CreateInstance(PP_Instance instance) { |
| + return new TestInstance(instance); |
| + } |
| +}; |
| + |
| +namespace pp { |
| +Module* CreateModule() { |
| + return new TestModule(); |
| +} |
| +} |
| + |
| +int main() { |
| + load_manifest(&__nacl_irt_query); |
| + return PpapiPluginMain(); |
| +} |