Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ppapi/tests/test_console.h" | |
| 6 | |
| 7 #include "ppapi/cpp/module.h" | |
| 8 #include "ppapi/tests/testing_instance.h" | |
| 9 | |
| 10 REGISTER_TEST_CASE(Console); | |
| 11 | |
| 12 TestConsole::TestConsole(TestingInstance* instance) | |
| 13 : TestCase(instance), | |
| 14 console_interface_(NULL) { | |
| 15 } | |
| 16 | |
| 17 bool TestConsole::Init() { | |
| 18 console_interface_ = static_cast<const PPB_Console*>( | |
| 19 pp::Module::Get()->GetBrowserInterface(PPB_CONSOLE_INTERFACE)); | |
| 20 var_interface_ = static_cast<const PPB_Var*>( | |
| 21 pp::Module::Get()->GetBrowserInterface(PPB_VAR_INTERFACE)); | |
| 22 return !!console_interface_ && !!var_interface_; | |
| 23 } | |
| 24 | |
| 25 void TestConsole::RunTests(const std::string& filter) { | |
| 26 RUN_TEST(Smoke, filter); | |
| 27 } | |
| 28 | |
| 29 std::string TestConsole::TestSmoke() { | |
| 30 // This test does not verify the log message actually reaches the console, but | |
| 31 // it does test that the interface exists and that it can be called without | |
| 32 // crashing. | |
| 33 const std::string source_str = "somewhere"; | |
| 34 PP_Var source = var_interface_->VarFromUtf8(source_str.c_str(), | |
| 35 source_str.length()); | |
| 36 | |
| 37 const std::string message_str = "hello, world."; | |
| 38 PP_Var message = var_interface_->VarFromUtf8(message_str.c_str(), | |
| 39 message_str.length()); | |
| 40 | |
| 41 console_interface_->Log(instance()->pp_instance(), PP_LOGLEVEL_ERROR, | |
| 42 message); | |
| 43 console_interface_->LogWithSource(instance()->pp_instance(), PP_LOGLEVEL_LOG, | |
| 44 source, message); | |
| 45 | |
| 46 var_interface_->Release(message); | |
| 47 var_interface_->Release(source); | |
|
dmichael (off chromium)
2012/12/12 19:09:07
It might be cleaner to just use pp::Var; string co
| |
| 48 | |
| 49 PASS(); | |
| 50 } | |
| OLD | NEW |