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

Side by Side Diff: ppapi/native_client/tests/ppapi_browser/ppb_widget/ppapi_ppb_widget.cc

Issue 7740013: Cloning a bunch of stuff from the native_client repository at r6528 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Native Client 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 "native_client/src/include/nacl_macros.h"
6 #include "native_client/src/shared/platform/nacl_check.h"
7 #include "native_client/tests/ppapi_test_lib/get_browser_interface.h"
8 #include "native_client/tests/ppapi_test_lib/test_interface.h"
9 #include "ppapi/c/dev/ppb_scrollbar_dev.h"
10 #include "ppapi/c/dev/ppb_widget_dev.h"
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_errors.h"
13 #include "ppapi/c/pp_rect.h"
14 #include "ppapi/c/ppb_core.h"
15 #include "ppapi/c/ppb_image_data.h"
16 #include "ppapi/c/ppb_url_loader.h"
17 #include "ppapi/c/ppp_messaging.h"
18
19 namespace {
20
21 const PP_Bool kVertical = PP_TRUE;
22
23 // The only widgets that are currently implemented are scrollbars.
24
25 // Test the PPB_Widget_Dev::IsWidget() method.
26 void TestIsWidget() {
27 EXPECT(PPBWidgetDev()->IsWidget(kInvalidResource) == PP_FALSE);
28 EXPECT(PPBWidgetDev()->IsWidget(kNotAResource) == PP_FALSE);
29
30 PP_Resource url_loader = PPBURLLoader()->Create(pp_instance());
31 CHECK(url_loader != kInvalidResource);
32 EXPECT(PPBWidgetDev()->IsWidget(url_loader) == PP_FALSE);
33 PPBCore()->ReleaseResource(url_loader);
34
35 PP_Resource scrollbar = PPBScrollbarDev()->Create(pp_instance(), kVertical);
36 EXPECT(PPBWidgetDev()->IsWidget(scrollbar) == PP_TRUE);
37
38 PPBCore()->ReleaseResource(scrollbar);
39
40 EXPECT(PPBWidgetDev()->IsWidget(scrollbar) == PP_FALSE);
41
42 TEST_PASSED;
43 }
44
45 // Test the PPB_Widget_Dev::GetLocation() and SetLocation() methods.
46 void TestLocation() {
47 PP_Resource scrollbar = PPBScrollbarDev()->Create(pp_instance(), kVertical);
48 PP_Rect location = { {1, 2}, {3, 4} };
49 PPBWidgetDev()->SetLocation(scrollbar, &location);
50 PP_Rect get_location = { {0, 0}, {1, 1} };
51 PPBWidgetDev()->GetLocation(scrollbar, &get_location);
52 EXPECT(
53 get_location.point.x == location.point.x &&
54 get_location.point.y == location.point.y &&
55 get_location.size.width == location.size.width &&
56 get_location.size.height == location.size.height);
57
58 PP_Rect far_and_big = { {1000000, 1000000}, {1000000, 1000000} };
59 PPBWidgetDev()->SetLocation(scrollbar, &far_and_big);
60 PPBWidgetDev()->GetLocation(scrollbar, &get_location);
61 EXPECT(
62 get_location.point.x == far_and_big.point.x &&
63 get_location.point.y == far_and_big.point.y &&
64 get_location.size.width == far_and_big.size.width &&
65 get_location.size.height == far_and_big.size.height);
66
67 PP_Rect neg_location = { {-1, -2}, {3, 4} };
68 PPBWidgetDev()->SetLocation(scrollbar, &neg_location);
69 PPBWidgetDev()->GetLocation(scrollbar, &get_location);
70 EXPECT(
71 get_location.point.x == neg_location.point.x &&
72 get_location.point.y == neg_location.point.y &&
73 get_location.size.width == neg_location.size.width &&
74 get_location.size.height == neg_location.size.height);
75
76 // TODO(bbudge) Add test for negative size components.
77 // http://code.google.com/p/chromium/issues/detail?id=90792
78
79 PPBCore()->ReleaseResource(scrollbar);
80
81 TEST_PASSED;
82 }
83
84 } // namespace
85
86 void SetupTests() {
87 RegisterTest("TestIsWidget", TestIsWidget);
88 RegisterTest("TestLocation", TestLocation);
89 }
90
91 void SetupPluginInterfaces() {
92 }
93
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698