8#include <wrl/implements.h>
10#include "base/win/scoped_com_initializer.h"
12#include "testing/gtest/include/gtest/gtest.h"
17TEST(EnumVariantTest, EmptyEnumVariant) {
18 ScopedCOMInitializer com_initializer;
20 Microsoft::WRL::ComPtr<EnumVariant> ev = Microsoft::WRL::Make<EnumVariant>(0);
21 Microsoft::WRL::ComPtr<IEnumVARIANT> ienumvariant;
22 ASSERT_TRUE(
SUCCEEDED(ev->QueryInterface(IID_PPV_ARGS(&ienumvariant))));
26 ULONG out_received = 0;
27 EXPECT_EQ(S_FALSE, ev->Next(1, out_element.
Receive(), &out_received));
28 EXPECT_EQ(0u, out_received);
31 EXPECT_EQ(S_FALSE, ev->Skip(1));
33 EXPECT_EQ(S_OK, ev->Reset());
35 Microsoft::WRL::ComPtr<IEnumVARIANT> ev2;
36 EXPECT_EQ(S_OK, ev->Clone(&ev2));
38 EXPECT_NE(
nullptr, ev2);
40 EXPECT_EQ(S_FALSE, ev2->Skip(1));
41 EXPECT_EQ(S_OK, ev2->Reset());
44TEST(EnumVariantTest, SimpleEnumVariant) {
45 ScopedCOMInitializer com_initializer;
47 Microsoft::WRL::ComPtr<EnumVariant> ev = Microsoft::WRL::Make<EnumVariant>(3);
48 ev->ItemAt(0)->vt = VT_I4;
49 ev->ItemAt(0)->lVal = 10;
50 ev->ItemAt(1)->vt = VT_I4;
51 ev->ItemAt(1)->lVal = 20;
52 ev->ItemAt(2)->vt = VT_I4;
53 ev->ItemAt(2)->lVal = 30;
57 ULONG out_received_0 = 0;
58 EXPECT_EQ(S_OK, ev->Next(1, out_element_0.
Receive(), &out_received_0));
59 EXPECT_EQ(1u, out_received_0);
60 EXPECT_EQ(VT_I4, out_element_0.
ptr()->vt);
61 EXPECT_EQ(10, out_element_0.
ptr()->lVal);
63 EXPECT_EQ(S_OK, ev->Skip(1));
66 ULONG out_received_2 = 0;
67 EXPECT_EQ(S_OK, ev->Next(1, out_element_2.
Receive(), &out_received_2));
68 EXPECT_EQ(1u, out_received_2);
69 EXPECT_EQ(VT_I4, out_element_2.
ptr()->vt);
70 EXPECT_EQ(30, out_element_2.
ptr()->lVal);
73 EXPECT_EQ(S_FALSE, ev->Next(1, placeholder_variant.
Receive(),
nullptr));
76 ASSERT_EQ(S_OK, ev->Reset());
80 ULONG out_received_multiple;
81 for (
int i = 0;
i < 3; ++
i)
82 ::VariantInit(&out_elements[
i]);
83 EXPECT_EQ(S_OK, ev->Next(3, out_elements, &out_received_multiple));
84 EXPECT_EQ(3u, out_received_multiple);
85 EXPECT_EQ(VT_I4, out_elements[0].vt);
86 EXPECT_EQ(10, out_elements[0].lVal);
87 EXPECT_EQ(VT_I4, out_elements[1].vt);
88 EXPECT_EQ(20, out_elements[1].lVal);
89 EXPECT_EQ(VT_I4, out_elements[2].vt);
90 EXPECT_EQ(30, out_elements[2].lVal);
91 for (
int i = 0;
i < 3; ++
i)
92 ::VariantClear(&out_elements[
i]);
96 ev->Next(1, placeholder_variant_multiple.
Receive(),
nullptr));
99TEST(EnumVariantTest, Clone) {
100 ScopedCOMInitializer com_initializer;
102 Microsoft::WRL::ComPtr<EnumVariant> ev = Microsoft::WRL::Make<EnumVariant>(3);
103 ev->ItemAt(0)->vt = VT_I4;
104 ev->ItemAt(0)->lVal = 10;
105 ev->ItemAt(1)->vt = VT_I4;
106 ev->ItemAt(1)->lVal = 20;
107 ev->ItemAt(2)->vt = VT_I4;
108 ev->ItemAt(2)->lVal = 30;
111 Microsoft::WRL::ComPtr<IEnumVARIANT> ev2;
112 EXPECT_EQ(S_OK, ev->Clone(&ev2));
116 for (
int i = 0;
i < 3; ++
i)
117 ::VariantInit(&out_elements[
i]);
118 EXPECT_EQ(S_OK, ev2->Next(3, out_elements,
nullptr));
119 EXPECT_EQ(VT_I4, out_elements[0].vt);
120 EXPECT_EQ(10, out_elements[0].lVal);
121 EXPECT_EQ(VT_I4, out_elements[1].vt);
122 EXPECT_EQ(20, out_elements[1].lVal);
123 EXPECT_EQ(VT_I4, out_elements[2].vt);
124 EXPECT_EQ(30, out_elements[2].lVal);
125 for (
int i = 0;
i < 3; ++
i)
126 ::VariantClear(&out_elements[
i]);
const VARIANT * ptr() const
TEST(Display, ScaleFactorToFloat)
#define EXPECT_TRUE(handle)