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

Side by Side Diff: remoting/client/plugin/chromoting_plugin_unittest.cc

Issue 2690003: Copy the (early prototype of) remoting in Chrome into the public tree.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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 "base/logging.h"
6 #include "base/scoped_ptr.h"
7 #include "remoting/client/plugin/chromoting_plugin.h"
8 #include "remoting/client/pepper/fake_browser.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 // Routine to create the PepperPlugin subclass that implements all of the
12 // plugin-specific functionality.
13 pepper::PepperPlugin* CreatePlugin(NPNetscapeFuncs* browser_funcs,
14 NPP instance);
15
16
17 class ChromotingPluginTest : public testing::Test {
18 protected:
19
20 virtual void SetUp() {
21 // Set up the fake browser callback routines.
22 fake_browser_ = Singleton<FakeBrowser>::get();
23 NPNetscapeFuncs* browser_funcs_ = fake_browser_->GetBrowserFuncs();
24 instance_.reset(new NPP_t());
25
26 // Create the ChromotingPlugin for testing.
27 pepper::PepperPlugin* pepper_plugin;
28 pepper_plugin = CreatePlugin(browser_funcs_, instance_.get());
29 plugin_.reset(
30 reinterpret_cast<remoting::ChromotingPlugin*>(pepper_plugin));
31 }
32
33 virtual void TearDown() {
34 }
35
36 FakeBrowser* fake_browser_;
37 scoped_ptr<NPP_t> instance_;
38 scoped_ptr<remoting::ChromotingPlugin> plugin_;
39 };
40
41 TEST_F(ChromotingPluginTest, TestSetup) {
42 ASSERT_TRUE(plugin_->browser() != NULL);
43 ASSERT_TRUE(plugin_->extensions() != NULL);
44 ASSERT_TRUE(plugin_->instance() != NULL);
45
46 ASSERT_TRUE(plugin_->device() != NULL);
47 }
48
49 TEST_F(ChromotingPluginTest, TestNew) {
50 NPMIMEType mimetype =
51 const_cast<NPMIMEType>("pepper-application/x-chromoting-plugin");
52 int16 argc;
53 char* argn[4];
54 char* argv[4];
55 NPError result;
56
57 // Test 0 arguments (NULL arrays).
58 argc = 0;
59 result = plugin_->New(mimetype, argc, NULL, NULL);
60 ASSERT_EQ(NPERR_GENERIC_ERROR, result);
61
62 // Test 0 arguments.
63 argc = 0;
64 result = plugin_->New(mimetype, argc, argn, argv);
65 ASSERT_EQ(NPERR_GENERIC_ERROR, result);
66
67 // Test 1 argument (missing "src").
68 argc = 1;
69 argn[0] = const_cast<char*>("noturl");
70 argv[0] = const_cast<char*>("random.value");
71 result = plugin_->New(mimetype, argc, argn, argv);
72 ASSERT_EQ(NPERR_GENERIC_ERROR, result);
73
74 // Test "src" argument.
75 argc = 1;
76 argn[0] = const_cast<char*>("src");
77 argv[0] = const_cast<char*>("chromotocol:name@chromoting.org");
78 result = plugin_->New(mimetype, argc, argn, argv);
79 ASSERT_EQ(NPERR_NO_ERROR, result);
80 }
81
82
83 static uint32 get_pixel(uint32* pixels, int stride, int x, int y) {
84 return pixels[((x) + ((y) * (stride >> 2)))];
85 }
86
87 TEST_F(ChromotingPluginTest, TestSetWindow) {
88 NPWindow* window = fake_browser_->GetWindow();
89 NPError result;
90
91 result = plugin_->SetWindow(window);
92 ASSERT_EQ(NPERR_NO_ERROR, result);
93 }
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_plugin_test.html ('k') | remoting/client/plugin/chromotocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698