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;
34     TIMELINE_MAJOR_TYPE type;
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         {
59             case TIMELINE_MAJOR_TYPE_COMPOSITE:
60             case TIMELINE_MAJOR_TYPE_TRACK:
61             case TIMELINE_MAJOR_TYPE_SOURCE:
62             case TIMELINE_MAJOR_TYPE_TRANSITION:
63             case TIMELINE_MAJOR_TYPE_EFFECT:
64             case TIMELINE_MAJOR_TYPE_GROUP:
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);
96         if (type == TIMELINE_MAJOR_TYPE_COMPOSITE)
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 
111 START_TEST(timeline)
112 {
113     CoInitialize(NULL);
114     test_timeline();
115     CoUninitialize();
116 }
117