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

Unified Diff: ppapi/tests/test_console.cc

Issue 11416214: PPAPI: Move PPB_Console out of dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test Created 8 years 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
Index: ppapi/tests/test_console.cc
diff --git a/ppapi/tests/test_console.cc b/ppapi/tests/test_console.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9fe5b492becf92ea370e40637f3837b48bcf57a0
--- /dev/null
+++ b/ppapi/tests/test_console.cc
@@ -0,0 +1,50 @@
+// Copyright (c) 2012 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_console.h"
+
+#include "ppapi/cpp/module.h"
+#include "ppapi/tests/testing_instance.h"
+
+REGISTER_TEST_CASE(Console);
+
+TestConsole::TestConsole(TestingInstance* instance)
+ : TestCase(instance),
+ console_interface_(NULL) {
+}
+
+bool TestConsole::Init() {
+ console_interface_ = static_cast<const PPB_Console*>(
+ pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE));
+ var_interface_ = static_cast<const PPB_Var*>(
+ pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE));
+ return !!console_interface_ && !!var_interface_;
+}
+
+void TestConsole::RunTests(const std::string& filter) {
+ RUN_TEST(Smoke, filter);
+}
+
+std::string TestConsole::TestSmoke() {
+ // This test does not verify the log message actually reaches the console, but
+ // it does test that the interface exists and that it can be called without
+ // crashing.
+ const std::string source_str = "somewhere";
+ PP_Var source = var_interface_->VarFromUtf8(source_str.c_str(),
+ source_str.length());
+
+ const std::string message_str = "hello, world.";
+ PP_Var message = var_interface_->VarFromUtf8(message_str.c_str(),
+ message_str.length());
+
+ console_interface_->Log(instance()->pp_instance(), PP_LOGLEVEL_ERROR,
+ message);
+ console_interface_->LogWithSource(instance()->pp_instance(), PP_LOGLEVEL_LOG,
+ source, message);
+
+ var_interface_->Release(message);
+ var_interface_->Release(source);
+
+ PASS();
+}

Powered by Google App Engine
This is Rietveld 408576698