ReactOS  0.4.14-dev-999-g61c8d34
timeline.c
Go to the documentation of this file.
1 /*
2  * Unit tests for Timeline
3  *
4  * Copyright (C) 2016 Alex Henrie
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #define COBJMACROS
22 #define CONST_VTABLE
23 
24 #include "wine/test.h"
25 #include "qedit.h"
26 
27 static void test_timeline(void)
28 {
29  HRESULT hr;
30  IAMTimeline *timeline = NULL;
31  IAMTimeline *timeline2 = (IAMTimeline *)0xdeadbeef;
32  IAMTimelineObj *obj = (IAMTimelineObj *)0xdeadbeef;
33  IAMTimelineObj obj_iface;
35 
36  hr = CoCreateInstance(&CLSID_AMTimeline, NULL, CLSCTX_INPROC_SERVER, &IID_IAMTimeline, (void **)&timeline);
37  ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "CoCreateInstance failed: %08x\n", hr);
38  if (!timeline) return;
39 
40  hr = IAMTimeline_QueryInterface(timeline, &IID_IAMTimelineObj, NULL);
41  ok(hr == E_POINTER, "Expected E_POINTER got %08x\n", hr);
42 
43  hr = IAMTimeline_QueryInterface(timeline, &IID_IAMTimelineObj, (void **)&obj);
44  ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE got %08x\n", hr);
45  ok(!obj, "Expected NULL got %p\n", obj);
46 
47  hr = IAMTimeline_CreateEmptyNode(timeline, NULL, 0);
48  ok(hr == E_POINTER, "Expected E_POINTER got %08x\n", hr);
49 
50  hr = IAMTimeline_CreateEmptyNode(timeline, NULL, TIMELINE_MAJOR_TYPE_COMPOSITE);
51  ok(hr == E_POINTER, "Expected E_POINTER got %08x\n", hr);
52 
53  for (type = 0; type < 256; type++)
54  {
55  obj = &obj_iface;
56  hr = IAMTimeline_CreateEmptyNode(timeline, &obj, type);
57  switch (type)
58  {
65  ok(hr == S_OK, "CreateEmptyNode failed: %08x\n", hr);
66  if (obj != &obj_iface) IAMTimelineObj_Release(obj);
67  break;
68  default:
69  ok(hr == E_INVALIDARG, "Expected E_INVALIDARG got %08x\n", hr);
70  ok(obj == &obj_iface, "Expected %p got %p\n", &obj_iface, obj);
71  }
72  }
73 
74  obj = NULL;
75  hr = IAMTimeline_CreateEmptyNode(timeline, &obj, TIMELINE_MAJOR_TYPE_COMPOSITE);
76  ok(hr == S_OK, "CreateEmptyNode failed: %08x\n", hr);
77  if (!obj) return;
78 
79  hr = IAMTimelineObj_QueryInterface(obj, &IID_IAMTimeline, NULL);
80  ok(hr == E_POINTER, "Expected E_POINTER got %08x\n", hr);
81 
82  hr = IAMTimelineObj_QueryInterface(obj, &IID_IAMTimeline, (void **)&timeline2);
83  ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE got %08x\n", hr);
84  ok(!timeline2, "Expected NULL got %p\n", timeline2);
85 
86  hr = IAMTimelineObj_GetTimelineType(obj, NULL);
87  ok(hr == E_POINTER, "Expected E_POINTER got %08x\n", hr);
88 
89  hr = IAMTimelineObj_GetTimelineType(obj, &type);
90  ok(hr == S_OK, "GetTimelineType failed: %08x\n", hr);
91  ok(type == TIMELINE_MAJOR_TYPE_COMPOSITE, "Expected TIMELINE_MAJOR_TYPE_COMPOSITE got %d\n", type);
92 
93  for (type = 0; type < 256; type++)
94  {
95  hr = IAMTimelineObj_SetTimelineType(obj, type);
97  ok(hr == S_OK, "SetTimelineType failed: %08x\n", hr);
98  else
99  ok(hr == E_INVALIDARG, "Expected E_INVALIDARG got %08x\n", hr);
100  }
101 
102  hr = IAMTimelineObj_GetTimelineNoRef(obj, NULL);
103  ok(hr == E_POINTER, "Expected E_POINTER got %08x\n", hr);
104 
105  timeline2 = (IAMTimeline *)0xdeadbeef;
106  hr = IAMTimelineObj_GetTimelineNoRef(obj, &timeline2);
107  ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE got %08x\n", hr);
108  ok(!timeline2, "Expected NULL got %p\n", timeline2);
109 
110  IAMTimelineObj_Release(obj);
111  IAMTimeline_Release(timeline);
112 }
113 
115 {
116  HRESULT hr;
117  IAMTimeline *timeline = NULL;
119 
120  hr = CoCreateInstance(&CLSID_AMTimeline, NULL, CLSCTX_INPROC_SERVER, &IID_IAMTimeline, (void **)&timeline);
121  ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG), "CoCreateInstance failed: %08x\n", hr);
122  if (!timeline)
123  return;
124 
125  hr = IAMTimeline_CreateEmptyNode(timeline, &obj, TIMELINE_MAJOR_TYPE_GROUP);
126  ok(hr == S_OK, "CreateEmptyNode failed: %08x\n", hr);
127  if(hr == S_OK)
128  {
130  IAMTimelineObj *obj2;
131 
132  hr = IAMTimelineObj_QueryInterface(obj, &IID_IAMTimelineGroup, (void **)&group);
133  ok(hr == S_OK, "got %08x\n", hr);
134 
135  hr = IAMTimelineGroup_QueryInterface(group, &IID_IAMTimelineObj, (void **)&obj2);
136  ok(hr == S_OK, "got %08x\n", hr);
137  ok(obj == obj2, "Different pointers\n");
138  IAMTimelineObj_Release(obj2);
139 
140  IAMTimelineGroup_Release(group);
141 
142  IAMTimelineObj_Release(obj);
143  }
144 
145  IAMTimeline_Release(timeline);
146 }
147 
148 START_TEST(timeline)
149 {
151  test_timeline();
153  CoUninitialize();
154 }
#define E_NOINTERFACE
Definition: winerror.h:2364
TIMELINE_MAJOR_TYPE
Definition: qedit.idl:302
HRESULT hr
Definition: shlfolder.c:183
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizei GLsizei GLuint * obj
Definition: glext.h:6042
#define E_INVALIDARG
Definition: ddrawi.h:101
START_TEST(timeline)
Definition: timeline.c:148
smooth NULL
Definition: ftsmooth.c:416
GLboolean GLuint group
Definition: glext.h:11120
LONG HRESULT
Definition: typedefs.h:78
#define broken(x)
Definition: _sntprintf.h:21
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define S_OK
Definition: intsafe.h:59
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696
static void test_timeline(void)
Definition: timeline.c:27
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define ok(value,...)
Definition: atltest.h:57
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
#define E_POINTER
Definition: winerror.h:2365
static void test_timelineobj_interfaces(void)
Definition: timeline.c:114