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

Unified Diff: ppapi/tests/test_var.cc

Issue 6673098: Remove PPB_Var interface's scripting functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removing convert. Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ppapi/tests/test_var.h ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/tests/test_var.cc
diff --git a/ppapi/tests/test_var.cc b/ppapi/tests/test_var.cc
deleted file mode 100644
index c9a13396ddf2120ea7b4f847b97b8d38a30ab6ea..0000000000000000000000000000000000000000
--- a/ppapi/tests/test_var.cc
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright (c) 2010 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.
-
-#include "ppapi/tests/test_var.h"
-
-#include <limits>
-
-#include "ppapi/c/pp_var.h"
-#include "ppapi/c/ppb_var.h"
-#include "ppapi/cpp/module.h"
-#include "ppapi/cpp/var.h"
-#include "ppapi/tests/test_utils.h"
-#include "ppapi/tests/testing_instance.h"
-
-REGISTER_TEST_CASE(Var);
-
-namespace {
-pp::Var adoptVar(PP_Var var) {
- return pp::Var(pp::Var::PassRef(), var);
-}
-} // namespace
-
-bool TestVar::Init() {
- var_interface_ = reinterpret_cast<PPB_Var const*>(
- pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE));
- return var_interface_ && InitTestingInterface();
-}
-
-void TestVar::RunTest() {
- RUN_TEST(ConvertType);
- RUN_TEST(DefineProperty);
-}
-
-std::string TestVar::TestConvertType() {
- pp::Var result;
- PP_Var exception = PP_MakeUndefined();
- double NaN = std::numeric_limits<double>::quiet_NaN();
-
- // Int to string
- result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(),
- pp::Var(100).pp_var(),
- PP_VARTYPE_STRING,
- &exception));
- ASSERT_EQ(pp::Var("100"), result);
- ASSERT_TRUE(adoptVar(exception).is_undefined());
-
- // Int to double
- result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(),
- pp::Var(100).pp_var(),
- PP_VARTYPE_DOUBLE,
- &exception));
- ASSERT_EQ(pp::Var(100.0), result);
- ASSERT_TRUE(adoptVar(exception).is_undefined());
-
- // Double to int
- result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(),
- pp::Var(100.0).pp_var(),
- PP_VARTYPE_INT32,
- &exception));
- ASSERT_EQ(pp::Var(100), result);
- ASSERT_TRUE(adoptVar(exception).is_undefined());
-
- // Double(NaN) to int
- result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(),
- pp::Var(NaN).pp_var(),
- PP_VARTYPE_INT32,
- &exception));
- ASSERT_EQ(pp::Var(0), result);
- ASSERT_TRUE(adoptVar(exception).is_undefined());
-
- // Double to string
- result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(),
- pp::Var(100.0).pp_var(),
- PP_VARTYPE_STRING,
- &exception));
- ASSERT_EQ(pp::Var("100"), result);
- ASSERT_TRUE(adoptVar(exception).is_undefined());
-
- // Double(NaN) to string
- result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(),
- pp::Var(NaN).pp_var(),
- PP_VARTYPE_STRING,
- &exception));
- ASSERT_EQ(pp::Var("NaN"), result);
- ASSERT_TRUE(adoptVar(exception).is_undefined());
-
- // String to int, valid string
- result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(),
- pp::Var("100").pp_var(),
- PP_VARTYPE_INT32,
- &exception));
- ASSERT_EQ(pp::Var(100), result);
- ASSERT_TRUE(adoptVar(exception).is_undefined());
-
- // String to int, invalid string
- result = adoptVar(var_interface_->ConvertType(instance_->pp_instance(),
- pp::Var("jockey").pp_var(),
- PP_VARTYPE_INT32,
- &exception));
- ASSERT_EQ(pp::Var(0), result);
- ASSERT_TRUE(adoptVar(exception).is_undefined());
-
- PASS();
-}
-
-std::string TestVar::TestDefineProperty() {
- pp::Var exception;
- pp::Var property;
- pp::Var value;
- PP_Var unmanaged_exception = PP_MakeUndefined();
-
- // Create an empty object.
- pp::Var test_obj = instance_->ExecuteScript("({})", &exception);
- ASSERT_TRUE(exception.is_undefined());
- ASSERT_TRUE(test_obj.is_object());
-
- // Define a simple property.
- property = "x";
- value = 1001;
- var_interface_->DefineProperty(test_obj.pp_var(),
- PP_MakeSimpleProperty(property.pp_var(),
- value.pp_var()),
- &unmanaged_exception);
- ASSERT_TRUE(adoptVar(unmanaged_exception).is_undefined());
-
- ASSERT_EQ(value, test_obj.GetProperty(property, &exception));
- ASSERT_TRUE(exception.is_undefined());
-
- // Define a property with a getter that always returns 123 and setter that
- // sets another property to the given value.
- property = "y";
- pp::Var getter = instance_->ExecuteScript(
- "(function(){return 'okey';})", &exception);
- ASSERT_TRUE(getter.is_object());
- ASSERT_TRUE(exception.is_undefined());
- pp::Var setter = instance_->ExecuteScript(
- "(function(x){this['another']=x;})", &exception);
- ASSERT_TRUE(setter.is_object());
- ASSERT_TRUE(exception.is_undefined());
-
- struct PP_ObjectProperty property_attributes = {
- property.pp_var(),
- PP_MakeUndefined(),
- getter.pp_var(),
- setter.pp_var(),
- PP_OBJECTPROPERTY_MODIFIER_NONE
- };
- var_interface_->DefineProperty(test_obj.pp_var(), property_attributes,
- &unmanaged_exception);
- ASSERT_TRUE(adoptVar(unmanaged_exception).is_undefined());
-
- value = test_obj.GetProperty(property, &exception);
- ASSERT_EQ(pp::Var("okey"), value);
- ASSERT_TRUE(exception.is_undefined());
-
- value = test_obj.GetProperty("another", &exception);
- ASSERT_TRUE(value.is_undefined());
- ASSERT_TRUE(exception.is_undefined());
-
- test_obj.SetProperty("another", "dokey", &exception);
- ASSERT_TRUE(exception.is_undefined());
-
- ASSERT_EQ(pp::Var("dokey"), test_obj.GetProperty("another", &exception));
- ASSERT_TRUE(exception.is_undefined());
-
- PASS();
-}
« no previous file with comments | « ppapi/tests/test_var.h ('k') | webkit/glue/webkit_glue.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698