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

Side by Side Diff: ppapi/native_client/tests/ppapi_geturl/module.cc

Issue 8589005: Remove NaCl file from ppapi_geturl test. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "native_client/tests/ppapi_geturl/module.h" 5 #include "native_client/tests/ppapi_geturl/module.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <string.h> 9 #include <string.h>
10 10
11 #include <string> 11 #include <string>
12 12
13 #include "native_client/src/include/nacl_macros.h" 13 #include "native_client/src/include/nacl_macros.h"
14 #include "native_client/src/include/portability.h" 14 #include "native_client/src/include/portability.h"
15 #include "native_client/src/shared/platform/nacl_check.h" 15 #include "native_client/src/shared/platform/nacl_check.h"
16 #include "native_client/src/untrusted/ppapi/nacl_file.h"
17 #include "native_client/tests/ppapi_geturl/nacl_file_main.h"
18 #include "native_client/tests/ppapi_geturl/url_load_request.h" 16 #include "native_client/tests/ppapi_geturl/url_load_request.h"
19 17
20 #include "ppapi/c/pp_completion_callback.h" 18 #include "ppapi/c/pp_completion_callback.h"
21 #include "ppapi/c/pp_errors.h" 19 #include "ppapi/c/pp_errors.h"
22 #include "ppapi/c/pp_var.h" 20 #include "ppapi/c/pp_var.h"
23 #include "ppapi/c/ppp_instance.h" 21 #include "ppapi/c/ppp_instance.h"
24 #include "ppapi/c/ppp_messaging.h" 22 #include "ppapi/c/ppp_messaging.h"
25 23
26 namespace { 24 namespace {
27 25
28 // These constants need to match their corresponding JavaScript values in 26 // These constants need to match their corresponding JavaScript values in
29 // ppapi_geturl.html. The JavaScript variables are all upper-case; for example 27 // ppapi_geturl.html. The JavaScript variables are all upper-case; for example
30 // kTrueStringValue corresponds to TRUE_STRING_VALUE. 28 // kTrueStringValue corresponds to TRUE_STRING_VALUE.
31 const char* const kLoadUrlMethodId = "loadUrl"; 29 const char* const kLoadUrlMethodId = "loadUrl";
32 const char* const kTrueStringValue = "1"; 30 const char* const kTrueStringValue = "1";
33 const char* const kFalseStringValue = "0"; 31 const char* const kFalseStringValue = "0";
34 static const char kArgumentSeparator = '|'; 32 static const char kArgumentSeparator = '|';
35 33
36 // A helper function to convert a bool to a string, used when assembling 34 // A helper function to convert a bool to a string, used when assembling
37 // messages posted back to the browser. |true| is converted to "1", |false| to 35 // messages posted back to the browser. |true| is converted to "1", |false| to
38 // "0". 36 // "0".
39 const std::string BoolToString(bool bool_value) { 37 const std::string BoolToString(bool bool_value) {
40 return bool_value ? kTrueStringValue : kFalseStringValue; 38 return bool_value ? kTrueStringValue : kFalseStringValue;
41 } 39 }
42 40
43 PPP_Instance instance_interface; 41 PPP_Instance instance_interface;
44 PPP_Messaging messaging_interface; 42 PPP_Messaging messaging_interface;
45 Module* singleton_ = NULL; 43 Module* singleton_ = NULL;
46 44
47 void RunTests(void* user_data) {
48 int* count = reinterpret_cast<int*>(user_data);
49 *count -= 1;
50 if (*count == 0)
51 test_nacl_file();
52 }
53 } // namespace 45 } // namespace
54 46
55 void HTMLLoaded(void* user_data, int32_t result) { 47 PP_Bool Instance_DidCreate(PP_Instance /*pp_instance*/,
56 CHECK(PP_OK == result);
57 printf("--- HTMLLoaded() SUCCESS: completion callback got PP_OK\n");
58 RunTests(user_data);
59 }
60
61 void RobotLoaded(void* user_data, int32_t result) {
62 CHECK(PP_ERROR_NOACCESS == result);
63 printf("--- RobotLoaded() SUCCESS: unable to LoadUrl on cross-domain\n");
64 RunTests(user_data);
65 }
66
67 void NonExistLoaded(void* user_data, int32_t result) {
68 CHECK(PP_ERROR_FAILED == result);
69 printf("--- NonExistLoaded() SUCCESS: callback got PP_ERROR_FAILED\n");
70 RunTests(user_data);
71 }
72
73 PP_Bool Instance_DidCreate(PP_Instance pp_instance,
74 uint32_t /*argc*/, 48 uint32_t /*argc*/,
75 const char* /*argn*/[], 49 const char* /*argn*/[],
76 const char* /*argv*/[]) { 50 const char* /*argv*/[]) {
77 printf("--- Instance_DidCreate\n"); 51 printf("--- Instance_DidCreate\n");
78 int* url_count = new int(3);
79 PP_CompletionCallback html_cb =
80 PP_MakeCompletionCallback(HTMLLoaded, url_count);
81 int32_t result = LoadUrl(pp_instance, "ppapi_geturl_success.html", html_cb);
82 CHECK(PP_OK_COMPLETIONPENDING == result);
83
84 PP_CompletionCallback robot_cb =
85 PP_MakeCompletionCallback(RobotLoaded, url_count);
86 result = LoadUrl(pp_instance, "http://www.google.com/robots.txt", robot_cb);
87 CHECK(PP_OK_COMPLETIONPENDING == result);
88
89 PP_CompletionCallback non_exist_cb =
90 PP_MakeCompletionCallback(NonExistLoaded, url_count);
91 result = LoadUrl(pp_instance, "ppapi_nonexistent_url.html", non_exist_cb);
92 CHECK(PP_OK_COMPLETIONPENDING == result);
93
94 return PP_TRUE; 52 return PP_TRUE;
95 } 53 }
96 54
97 void Instance_DidDestroy(PP_Instance /*instance*/) { 55 void Instance_DidDestroy(PP_Instance /*instance*/) {
98 printf("--- Instance_DidDestroy\n"); 56 printf("--- Instance_DidDestroy\n");
99 } 57 }
100 58
101 void Instance_DidChangeView(PP_Instance /*pp_instance*/, 59 void Instance_DidChangeView(PP_Instance /*pp_instance*/,
102 const PP_Rect* /*position*/, 60 const PP_Rect* /*position*/,
103 const PP_Rect* /*clip*/) { 61 const PP_Rect* /*clip*/) {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 printf("--- ReportResult posts result string:\n\t%s\n", result.c_str()); 270 printf("--- ReportResult posts result string:\n\t%s\n", result.c_str());
313 struct PP_Var var_result = StrToVar(result); 271 struct PP_Var var_result = StrToVar(result);
314 ppb_messaging_interface()->PostMessage(pp_instance, var_result); 272 ppb_messaging_interface()->PostMessage(pp_instance, var_result);
315 // If the message was created using VarFromUtf8() it needs to be released. 273 // If the message was created using VarFromUtf8() it needs to be released.
316 // See the comments about VarFromUtf8() in ppapi/c/ppb_var.h for more 274 // See the comments about VarFromUtf8() in ppapi/c/ppb_var.h for more
317 // information. 275 // information.
318 if (var_result.type == PP_VARTYPE_STRING) { 276 if (var_result.type == PP_VARTYPE_STRING) {
319 ppb_var_interface()->Release(var_result); 277 ppb_var_interface()->Release(var_result);
320 } 278 }
321 } 279 }
OLDNEW
« no previous file with comments | « ppapi/native_client/tests/ppapi_geturl/build.scons ('k') | ppapi/native_client/tests/ppapi_geturl/nacl.scons » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698