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

Side by Side Diff: ppapi/tests/test_var_deprecated.cc

Issue 8982006: Add GetLiveVars to PPB_Testing_Dev. Fix leaks it uncovered. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged Created 8 years, 12 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_var.cc ('k') | ppapi/tests/test_video_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ppapi/tests/test_var_deprecated.h" 5 #include "ppapi/tests/test_var_deprecated.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 return pp::Var(); 62 return pp::Var();
63 } 63 }
64 64
65 } // namespace 65 } // namespace
66 66
67 REGISTER_TEST_CASE(VarDeprecated); 67 REGISTER_TEST_CASE(VarDeprecated);
68 68
69 bool TestVarDeprecated::Init() { 69 bool TestVarDeprecated::Init() {
70 var_interface_ = static_cast<const PPB_Var_Deprecated*>( 70 var_interface_ = static_cast<const PPB_Var_Deprecated*>(
71 pp::Module::Get()->GetBrowserInterface(PPB_VAR_DEPRECATED_INTERFACE)); 71 pp::Module::Get()->GetBrowserInterface(PPB_VAR_DEPRECATED_INTERFACE));
72 return var_interface_ && InitTestingInterface(); 72 return var_interface_ && CheckTestingInterface();
73 } 73 }
74 74
75 void TestVarDeprecated::RunTests(const std::string& filter) { 75 void TestVarDeprecated::RunTests(const std::string& filter) {
76 RUN_TEST(BasicString, filter); 76 RUN_TEST(BasicString, filter);
77 RUN_TEST(InvalidAndEmpty, filter); 77 RUN_TEST(InvalidAndEmpty, filter);
78 RUN_TEST(InvalidUtf8, filter); 78 RUN_TEST(InvalidUtf8, filter);
79 RUN_TEST(NullInputInUtf8Conversion, filter); 79 RUN_TEST(NullInputInUtf8Conversion, filter);
80 RUN_TEST(ValidUtf8, filter); 80 RUN_TEST(ValidUtf8, filter);
81 RUN_TEST(Utf8WithEmbeddedNulls, filter); 81 RUN_TEST(Utf8WithEmbeddedNulls, filter);
82 RUN_TEST(VarToUtf8ForWrongType, filter); 82 RUN_TEST(VarToUtf8ForWrongType, filter);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // Now convert it back. 172 // Now convert it back.
173 uint32_t length = kInvalidLength; 173 uint32_t length = kInvalidLength;
174 const char* result = NULL; 174 const char* result = NULL;
175 result = var_interface_->VarToUtf8(converted_string, &length); 175 result = var_interface_->VarToUtf8(converted_string, &length);
176 if (length != 0) { 176 if (length != 0) {
177 return "Expected 0 length string on conversion."; 177 return "Expected 0 length string on conversion.";
178 } 178 }
179 if (result == NULL) { 179 if (result == NULL) {
180 return "Expected a non-null result for 0-lengthed string from VarToUtf8."; 180 return "Expected a non-null result for 0-lengthed string from VarToUtf8.";
181 } 181 }
182 var_interface_->Release(converted_string);
182 183
183 // Should not crash, and make an empty string. 184 // Should not crash, and make an empty string.
184 const char* null_string = NULL; 185 const char* null_string = NULL;
185 pp::Var null_var(null_string); 186 pp::Var null_var(null_string);
186 if (!null_var.is_string() || null_var.AsString() != "") { 187 if (!null_var.is_string() || null_var.AsString() != "") {
187 return "Expected NULL input to make an empty string Var."; 188 return "Expected NULL input to make an empty string Var.";
188 } 189 }
189 190
190 PASS(); 191 PASS();
191 } 192 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 ASSERT_TRUE(var_from_page_.is_object()); 380 ASSERT_TRUE(var_from_page_.is_object());
380 381
381 // If the reference counting works, the object should be valid. We can test 382 // If the reference counting works, the object should be valid. We can test
382 // this by executing it (it was a function we defined above) and it should 383 // this by executing it (it was a function we defined above) and it should
383 // return "works" concatenated with the argument. 384 // return "works" concatenated with the argument.
384 pp::VarPrivate function(var_from_page_); 385 pp::VarPrivate function(var_from_page_);
385 pp::Var result = var_from_page_.Call(pp::Var(), "nice"); 386 pp::Var result = var_from_page_.Call(pp::Var(), "nice");
386 ASSERT_TRUE(result.is_string()); 387 ASSERT_TRUE(result.is_string());
387 ASSERT_TRUE(result.AsString() == "worksnice"); 388 ASSERT_TRUE(result.AsString() == "worksnice");
388 389
390 // Reset var_from_page_ so it doesn't seem like a leak to the var leak
391 // checking code.
392 var_from_page_ = pp::Var();
393
389 PASS(); 394 PASS();
390 } 395 }
391 396
OLDNEW
« no previous file with comments | « ppapi/tests/test_var.cc ('k') | ppapi/tests/test_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698