diff options
author | garykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 19:58:23 +0000 |
---|---|---|
committer | garykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-07 19:58:23 +0000 |
commit | cb3b1f93130040a150e7fcc57cd4d5a75569685a (patch) | |
tree | ff93665e3c1478c61663d1107cd42dc25b31448d /remoting/client/plugin/chromoting_plugin_unittest.cc | |
parent | b0110e822ac2b2db56d1b1542aad06da573cd544 (diff) | |
download | chromium_src-cb3b1f93130040a150e7fcc57cd4d5a75569685a.zip chromium_src-cb3b1f93130040a150e7fcc57cd4d5a75569685a.tar.gz chromium_src-cb3b1f93130040a150e7fcc57cd4d5a75569685a.tar.bz2 |
Copy the (early prototype of) remoting in Chrome into the public tree.
At the moment, this is a semi-functional demo.
BUG=none
TEST=build/run all unittests on linux
Review URL: http://codereview.chromium.org/2690003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49087 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/plugin/chromoting_plugin_unittest.cc')
-rw-r--r-- | remoting/client/plugin/chromoting_plugin_unittest.cc | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/remoting/client/plugin/chromoting_plugin_unittest.cc b/remoting/client/plugin/chromoting_plugin_unittest.cc new file mode 100644 index 0000000..68baa9c --- /dev/null +++ b/remoting/client/plugin/chromoting_plugin_unittest.cc @@ -0,0 +1,93 @@ +// 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 "base/logging.h" +#include "base/scoped_ptr.h" +#include "remoting/client/plugin/chromoting_plugin.h" +#include "remoting/client/pepper/fake_browser.h" +#include "testing/gtest/include/gtest/gtest.h" + +// Routine to create the PepperPlugin subclass that implements all of the +// plugin-specific functionality. +pepper::PepperPlugin* CreatePlugin(NPNetscapeFuncs* browser_funcs, + NPP instance); + + +class ChromotingPluginTest : public testing::Test { + protected: + + virtual void SetUp() { + // Set up the fake browser callback routines. + fake_browser_ = Singleton<FakeBrowser>::get(); + NPNetscapeFuncs* browser_funcs_ = fake_browser_->GetBrowserFuncs(); + instance_.reset(new NPP_t()); + + // Create the ChromotingPlugin for testing. + pepper::PepperPlugin* pepper_plugin; + pepper_plugin = CreatePlugin(browser_funcs_, instance_.get()); + plugin_.reset( + reinterpret_cast<remoting::ChromotingPlugin*>(pepper_plugin)); + } + + virtual void TearDown() { + } + + FakeBrowser* fake_browser_; + scoped_ptr<NPP_t> instance_; + scoped_ptr<remoting::ChromotingPlugin> plugin_; +}; + +TEST_F(ChromotingPluginTest, TestSetup) { + ASSERT_TRUE(plugin_->browser() != NULL); + ASSERT_TRUE(plugin_->extensions() != NULL); + ASSERT_TRUE(plugin_->instance() != NULL); + + ASSERT_TRUE(plugin_->device() != NULL); +} + +TEST_F(ChromotingPluginTest, TestNew) { + NPMIMEType mimetype = + const_cast<NPMIMEType>("pepper-application/x-chromoting-plugin"); + int16 argc; + char* argn[4]; + char* argv[4]; + NPError result; + + // Test 0 arguments (NULL arrays). + argc = 0; + result = plugin_->New(mimetype, argc, NULL, NULL); + ASSERT_EQ(NPERR_GENERIC_ERROR, result); + + // Test 0 arguments. + argc = 0; + result = plugin_->New(mimetype, argc, argn, argv); + ASSERT_EQ(NPERR_GENERIC_ERROR, result); + + // Test 1 argument (missing "src"). + argc = 1; + argn[0] = const_cast<char*>("noturl"); + argv[0] = const_cast<char*>("random.value"); + result = plugin_->New(mimetype, argc, argn, argv); + ASSERT_EQ(NPERR_GENERIC_ERROR, result); + + // Test "src" argument. + argc = 1; + argn[0] = const_cast<char*>("src"); + argv[0] = const_cast<char*>("chromotocol:name@chromoting.org"); + result = plugin_->New(mimetype, argc, argn, argv); + ASSERT_EQ(NPERR_NO_ERROR, result); +} + + +static uint32 get_pixel(uint32* pixels, int stride, int x, int y) { + return pixels[((x) + ((y) * (stride >> 2)))]; +} + +TEST_F(ChromotingPluginTest, TestSetWindow) { + NPWindow* window = fake_browser_->GetWindow(); + NPError result; + + result = plugin_->SetWindow(window); + ASSERT_EQ(NPERR_NO_ERROR, result); +} |