Flutter Engine
The Flutter Engine
Namespaces | Classes | Functions
base::win Namespace Reference

Namespaces

namespace  internal
 
namespace  test
 

Classes

class  EnumVariant
 
class  ScopedBstr
 
class  ScopedSafearray
 
class  ScopedVariant
 
class  VariantVector
 

Functions

float GetScaleFactorForHWND (HWND hwnd)
 
float ScaleFactorToFloat (DEVICE_SCALE_FACTOR scale_factor)
 
 TEST (Display, ScaleFactorToFloat)
 
 TEST (EnumVariantTest, EmptyEnumVariant)
 
 TEST (EnumVariantTest, SimpleEnumVariant)
 
 TEST (EnumVariantTest, Clone)
 
 TEST (ScopedBstrTest, Empty)
 
 TEST (ScopedBstrTest, Basic)
 
 TEST (ScopedBstrTest, Swap)
 
 TEST (ScopedBstrTest, OutParam)
 
 TEST (ScopedBstrTest, AllocateBytesAndSetByteLen)
 
 TEST (ScopedBstrTest, AllocateAndSetByteLen)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayMethods)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayMoveConstructor)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayMoveAssignOperator)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayCast)
 
 TEST (ScopedSafearrayTest, InitiallyEmpty)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayGetCount)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayInitialLockScope)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayLockScopeMoveConstructor)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayLockScopeMoveAssignOperator)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayLockScopeTypeMismatch)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayLockScopeRandomAccess)
 
 TEST (ScopedSafearrayTest, ScopedSafearrayLockScopeIterator)
 
 TEST (ScopedVariantTest, Empty)
 
 TEST (ScopedVariantTest, ConstructBstr)
 
 TEST (ScopedVariantTest, SetBstr)
 
 TEST (ScopedVariantTest, ReleaseBstr)
 
 TEST (ScopedVariantTest, ResetToEmptyBstr)
 
 TEST (ScopedVariantTest, TakeOwnershipBstr)
 
 TEST (ScopedVariantTest, SwapBstr)
 
 TEST (ScopedVariantTest, CompareBstr)
 
 TEST (ScopedVariantTest, ReceiveAndCopyBstr)
 
 TEST (ScopedVariantTest, SetBstrFromBstrVariant)
 
 TEST (ScopedVariantTest, SetDate)
 
 TEST (ScopedVariantTest, SetSigned1Byte)
 
 TEST (ScopedVariantTest, SetSigned2Byte)
 
 TEST (ScopedVariantTest, SetSigned4Byte)
 
 TEST (ScopedVariantTest, SetSigned8Byte)
 
 TEST (ScopedVariantTest, SetUnsigned1Byte)
 
 TEST (ScopedVariantTest, SetUnsigned2Byte)
 
 TEST (ScopedVariantTest, SetUnsigned4Byte)
 
 TEST (ScopedVariantTest, SetUnsigned8Byte)
 
 TEST (ScopedVariantTest, SetReal4Byte)
 
 TEST (ScopedVariantTest, SetReal8Byte)
 
 TEST (ScopedVariantTest, SetBooleanTrue)
 
 TEST (ScopedVariantTest, SetBooleanFalse)
 
 TEST (ScopedVariantTest, SetComIDispatch)
 
 TEST (ScopedVariantTest, SetComNullIDispatch)
 
 TEST (ScopedVariantTest, SetComIUnknown)
 
 TEST (ScopedVariantTest, SetComNullIUnknown)
 
 TEST (ScopedVariant, ScopedComIDispatchConstructor)
 
 TEST (ScopedVariant, ScopedComIDispatchMove)
 
 TEST (ScopedVariant, ScopedComIDispatchCopy)
 
 TEST (ScopedVariant, ScopedComIUnknownConstructor)
 
 TEST (ScopedVariant, ScopedComIUnknownWithRawVariant)
 
 TEST (ScopedVariant, SetSafeArray)
 
 TEST (ScopedVariant, SetNullSafeArray)
 
 TEST (VariantVectorTest, InitiallyEmpty)
 
 TEST (VariantVectorTest, MoveConstructor)
 
 TEST (VariantVectorTest, MoveAssignOperator)
 
 TEST (VariantVectorTest, Insert)
 
 TEST (VariantVectorTest, InsertCanUpcastDispatchToUnknown)
 
 TEST (VariantVectorTest, InsertCannotDowncastUnknownToDispatch)
 
 TEST (VariantVectorTest, Reset)
 
 TEST (VariantVectorTest, ResetWithManagedContents)
 
 TEST (VariantVectorTest, ScopeWithManagedContents)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantEmpty)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleBool)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleI1)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleUI1)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleI2)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleUI2)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleI4)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleUI4)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleI8)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleUI8)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleR4)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleR8)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleDate)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleBstr)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleUnknown)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantSingleDispatch)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleBool)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleI1)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleUI1)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleI2)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleUI2)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleI4)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleUI4)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleI8)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleUI8)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleR4)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleR8)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleDate)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleBstr)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleUnknown)
 
 TEST (VariantVectorTest, ReleaseAsScalarVariantMultipleDispatch)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantEmpty)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleBool)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleI1)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleUI1)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleI2)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleUI2)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleI4)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleUI4)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleI8)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleUI8)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleR4)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleR8)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleDate)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleBstr)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleUnknown)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantSingleDispatch)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleBool)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleI1)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleUI1)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleI2)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleUI2)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleI4)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleUI4)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleI8)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleUI8)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleR4)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleR8)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleDate)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleBstr)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleUnknown)
 
 TEST (VariantVectorTest, ReleaseAsSafearrayVariantMultipleDispatch)
 
 TEST (VariantVectorTest, CompareVariant)
 
 TEST (VariantVectorTest, CompareSafearray)
 
 TEST (VariantVectorTest, CompareVariantVector)
 

Function Documentation

◆ GetScaleFactorForHWND()

float base::win::GetScaleFactorForHWND ( HWND  hwnd)

Definition at line 74 of file display.cc.

74 {
75 HMONITOR monitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
76 DEVICE_SCALE_FACTOR scale = DEVICE_SCALE_FACTOR_INVALID;
77 if (SUCCEEDED(GetHelper()->GetScaleFactorForMonitor(monitor, &scale))) {
79 }
80 return 1.0f;
81}
float ScaleFactorToFloat(DEVICE_SCALE_FACTOR scale_factor)
Definition: display.cc:83
const Scalar scale
#define SUCCEEDED(hr)

◆ ScaleFactorToFloat()

float base::win::ScaleFactorToFloat ( DEVICE_SCALE_FACTOR  scale_factor)

Definition at line 83 of file display.cc.

83 {
84 switch (scale_factor) {
85 case SCALE_100_PERCENT:
86 return 1.0f;
87 case SCALE_120_PERCENT:
88 return 1.2f;
89 case SCALE_125_PERCENT:
90 return 1.25f;
91 case SCALE_140_PERCENT:
92 return 1.4f;
93 case SCALE_150_PERCENT:
94 return 1.5f;
95 case SCALE_160_PERCENT:
96 return 1.6f;
97 case SCALE_175_PERCENT:
98 return 1.75f;
99 case SCALE_180_PERCENT:
100 return 1.8f;
101 case SCALE_200_PERCENT:
102 return 2.0f;
103 case SCALE_225_PERCENT:
104 return 2.25f;
105 case SCALE_250_PERCENT:
106 return 2.5f;
107 case SCALE_300_PERCENT:
108 return 3.0f;
109 case SCALE_350_PERCENT:
110 return 3.5f;
111 case SCALE_400_PERCENT:
112 return 4.0f;
113 case SCALE_450_PERCENT:
114 return 4.5f;
115 case SCALE_500_PERCENT:
116 return 5.0f;
117 default:
118 return 1.0f;
119 }
120}

◆ TEST() [1/130]

base::win::TEST ( Display  ,
ScaleFactorToFloat   
)

Definition at line 12 of file display_unittest.cc.

12 {
13 EXPECT_EQ(ScaleFactorToFloat(SCALE_100_PERCENT), 1.00f);
14 EXPECT_EQ(ScaleFactorToFloat(SCALE_120_PERCENT), 1.20f);
15 EXPECT_EQ(ScaleFactorToFloat(SCALE_125_PERCENT), 1.25f);
16 EXPECT_EQ(ScaleFactorToFloat(SCALE_140_PERCENT), 1.40f);
17 EXPECT_EQ(ScaleFactorToFloat(SCALE_150_PERCENT), 1.50f);
18 EXPECT_EQ(ScaleFactorToFloat(SCALE_160_PERCENT), 1.60f);
19 EXPECT_EQ(ScaleFactorToFloat(SCALE_175_PERCENT), 1.75f);
20 EXPECT_EQ(ScaleFactorToFloat(SCALE_180_PERCENT), 1.80f);
21 EXPECT_EQ(ScaleFactorToFloat(SCALE_200_PERCENT), 2.00f);
22 EXPECT_EQ(ScaleFactorToFloat(SCALE_225_PERCENT), 2.25f);
23 EXPECT_EQ(ScaleFactorToFloat(SCALE_250_PERCENT), 2.50f);
24 EXPECT_EQ(ScaleFactorToFloat(SCALE_350_PERCENT), 3.50f);
25 EXPECT_EQ(ScaleFactorToFloat(SCALE_400_PERCENT), 4.00f);
26 EXPECT_EQ(ScaleFactorToFloat(SCALE_450_PERCENT), 4.50f);
27 EXPECT_EQ(ScaleFactorToFloat(SCALE_500_PERCENT), 5.00f);
28 EXPECT_EQ(ScaleFactorToFloat(DEVICE_SCALE_FACTOR_INVALID), 1.0f);
29}

◆ TEST() [2/130]

base::win::TEST ( EnumVariantTest  ,
Clone   
)

Definition at line 99 of file enum_variant_unittest.cc.

99 {
100 ScopedCOMInitializer com_initializer;
101
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;
109
110 // Clone it.
111 Microsoft::WRL::ComPtr<IEnumVARIANT> ev2;
112 EXPECT_EQ(S_OK, ev->Clone(&ev2));
113 EXPECT_TRUE(ev2 != nullptr);
114
115 VARIANT out_elements[3];
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]);
127}
#define EXPECT_TRUE(handle)
Definition: unit_test.h:678

◆ TEST() [3/130]

base::win::TEST ( EnumVariantTest  ,
EmptyEnumVariant   
)

Definition at line 17 of file enum_variant_unittest.cc.

17 {
18 ScopedCOMInitializer com_initializer;
19
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))));
23
24 {
25 base::win::ScopedVariant out_element;
26 ULONG out_received = 0;
27 EXPECT_EQ(S_FALSE, ev->Next(1, out_element.Receive(), &out_received));
28 EXPECT_EQ(0u, out_received);
29 }
30
31 EXPECT_EQ(S_FALSE, ev->Skip(1));
32
33 EXPECT_EQ(S_OK, ev->Reset());
34
35 Microsoft::WRL::ComPtr<IEnumVARIANT> ev2;
36 EXPECT_EQ(S_OK, ev->Clone(&ev2));
37
38 EXPECT_NE(nullptr, ev2);
39 EXPECT_NE(ev, ev2);
40 EXPECT_EQ(S_FALSE, ev2->Skip(1));
41 EXPECT_EQ(S_OK, ev2->Reset());
42}
DWORD ULONG
Definition: windows_types.h:40

◆ TEST() [4/130]

base::win::TEST ( EnumVariantTest  ,
SimpleEnumVariant   
)

Definition at line 44 of file enum_variant_unittest.cc.

44 {
45 ScopedCOMInitializer com_initializer;
46
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;
54
55 // Get elements one at a time from index 0 and 2.
56 base::win::ScopedVariant out_element_0;
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);
62
63 EXPECT_EQ(S_OK, ev->Skip(1));
64
65 base::win::ScopedVariant out_element_2;
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);
71
72 base::win::ScopedVariant placeholder_variant;
73 EXPECT_EQ(S_FALSE, ev->Next(1, placeholder_variant.Receive(), nullptr));
74
75 // Verify the reset works for the next step.
76 ASSERT_EQ(S_OK, ev->Reset());
77
78 // Get all elements at once.
79 VARIANT out_elements[3];
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]);
93
94 base::win::ScopedVariant placeholder_variant_multiple;
95 EXPECT_EQ(S_FALSE,
96 ev->Next(1, placeholder_variant_multiple.Receive(), nullptr));
97}
const VARIANT * ptr() const

◆ TEST() [5/130]

base::win::TEST ( ScopedBstrTest  ,
AllocateAndSetByteLen   
)

Definition at line 86 of file scoped_bstr_unittest.cc.

86 {
88 EXPECT_NE(nullptr, b.Allocate(kTestString2));
89 EXPECT_EQ(test2_len, b.Length());
90
91 b.SetByteLen((test2_len - 1) * sizeof(kTestString2[0]));
92 EXPECT_EQ(test2_len - 1, b.Length());
93}
static bool b

◆ TEST() [6/130]

base::win::TEST ( ScopedBstrTest  ,
AllocateBytesAndSetByteLen   
)

Definition at line 71 of file scoped_bstr_unittest.cc.

71 {
72 constexpr size_t num_bytes = 100;
74 EXPECT_NE(nullptr, b.AllocateBytes(num_bytes));
75 EXPECT_EQ(num_bytes, b.ByteLength());
76 EXPECT_EQ(num_bytes / sizeof(kTestString1[0]), b.Length());
77
78 lstrcpy(b.Get(), kTestString1);
79 EXPECT_EQ(test1_len, static_cast<size_t>(lstrlen(b.Get())));
80 EXPECT_EQ(num_bytes / sizeof(kTestString1[0]), b.Length());
81
82 b.SetByteLen(lstrlen(b.Get()) * sizeof(kTestString2[0]));
83 EXPECT_EQ(b.Length(), static_cast<size_t>(lstrlen(b.Get())));
84}

◆ TEST() [7/130]

base::win::TEST ( ScopedBstrTest  ,
Basic   
)

Definition at line 36 of file scoped_bstr_unittest.cc.

36 {
37 ScopedBstr b(kTestString1);
38 EXPECT_EQ(test1_len, b.Length());
39 EXPECT_EQ(test1_len * sizeof(kTestString1[0]), b.ByteLength());
40}

◆ TEST() [8/130]

base::win::TEST ( ScopedBstrTest  ,
Empty   
)

Definition at line 23 of file scoped_bstr_unittest.cc.

23 {
25 EXPECT_EQ(nullptr, b.Get());
26 EXPECT_EQ(0u, b.Length());
27 EXPECT_EQ(0u, b.ByteLength());
28 b.Reset(nullptr);
29 EXPECT_EQ(nullptr, b.Get());
30 EXPECT_EQ(nullptr, b.Release());
31 ScopedBstr b2;
32 b.Swap(b2);
33 EXPECT_EQ(nullptr, b.Get());
34}

◆ TEST() [9/130]

base::win::TEST ( ScopedBstrTest  ,
OutParam   
)

Definition at line 65 of file scoped_bstr_unittest.cc.

65 {
67 CreateTestString1(b.Receive());
68 EXPECT_STREQ(kTestString1, b.Get());
69}

◆ TEST() [10/130]

base::win::TEST ( ScopedBstrTest  ,
Swap   
)

Definition at line 50 of file scoped_bstr_unittest.cc.

50 {
51 ScopedBstr b1(kTestString1);
52 ScopedBstr b2;
53 b1.Swap(b2);
54 EXPECT_EQ(test1_len, b2.Length());
55 EXPECT_EQ(0u, b1.Length());
56 EXPECT_STREQ(kTestString1, b2.Get());
57
58 BSTR tmp = b2.Release();
59 EXPECT_NE(nullptr, tmp);
60 EXPECT_STREQ(kTestString1, tmp);
61 EXPECT_EQ(nullptr, b2.Get());
62 SysFreeString(tmp);
63}
void Swap(ScopedBstr &bstr2)
Definition: scoped_bstr.cc:56
BSTR Get() const
Definition: scoped_bstr.h:33
size_t Length() const
Definition: scoped_bstr.cc:83

◆ TEST() [11/130]

base::win::TEST ( ScopedSafearrayTest  ,
InitiallyEmpty   
)

Definition at line 142 of file scoped_safearray_unittest.cc.

142 {
143 ScopedSafearray empty_safe_array;
144 EXPECT_EQ(empty_safe_array.Get(), nullptr);
145 EXPECT_DCHECK_DEATH(empty_safe_array.GetCount());
146}
size_t GetCount(UINT dimension=0) const
#define EXPECT_DCHECK_DEATH(statement)
Definition: gtest_util.h:37

◆ TEST() [12/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayCast   
)

Definition at line 120 of file scoped_safearray_unittest.cc.

120 {
121 SAFEARRAY* safe_array = SafeArrayCreateVector(
122 VT_R8 /* element type */, 1 /* lower bound */, 5 /* elements */);
123 ScopedSafearray scoped_safe_array(safe_array);
124 EXPECT_EQ(SafeArrayGetDim(scoped_safe_array.Get()), 1U);
125
126 LONG lower_bound;
127 EXPECT_HRESULT_SUCCEEDED(
128 SafeArrayGetLBound(scoped_safe_array.Get(), 1, &lower_bound));
129 EXPECT_EQ(lower_bound, 1);
130
131 LONG upper_bound;
132 EXPECT_HRESULT_SUCCEEDED(
133 SafeArrayGetUBound(scoped_safe_array.Get(), 1, &upper_bound));
134 EXPECT_EQ(upper_bound, 5);
135
136 VARTYPE variable_type;
137 EXPECT_HRESULT_SUCCEEDED(
138 SafeArrayGetVartype(scoped_safe_array.Get(), &variable_type));
139 EXPECT_EQ(variable_type, VT_R8);
140}
long LONG
Definition: windows_types.h:23

◆ TEST() [13/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayGetCount   
)

Definition at line 148 of file scoped_safearray_unittest.cc.

148 {
149 // TODO(crbug.com/1082005): Create a safer alternative to SAFEARRAY methods.
150 ScopedSafearray scoped_safe_array(SafeArrayCreateVector(
151 /*vartype=*/VT_I4, /*lower_bound=*/2, /*element_count=*/5));
152 ASSERT_NE(scoped_safe_array.Get(), nullptr);
153 EXPECT_EQ(SafeArrayGetDim(scoped_safe_array.Get()), 1U);
154
155 LONG lower_bound;
156 EXPECT_HRESULT_SUCCEEDED(
157 SafeArrayGetLBound(scoped_safe_array.Get(), 1, &lower_bound));
158 EXPECT_EQ(lower_bound, 2);
159
160 LONG upper_bound;
161 EXPECT_HRESULT_SUCCEEDED(
162 SafeArrayGetUBound(scoped_safe_array.Get(), 1, &upper_bound));
163 EXPECT_EQ(upper_bound, 6);
164
165 EXPECT_EQ(scoped_safe_array.GetCount(), 5U);
166}

◆ TEST() [14/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayInitialLockScope   
)

Definition at line 168 of file scoped_safearray_unittest.cc.

168 {
169 ScopedSafearray scoped_safe_array;
170 std::optional<ScopedSafearray::LockScope<VT_I4>> lock_scope =
171 scoped_safe_array.CreateLockScope<VT_I4>();
172 EXPECT_FALSE(lock_scope.has_value());
173}
std::optional< LockScope< ElementVartype > > CreateLockScope() const

◆ TEST() [15/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayLockScopeIterator   
)

Definition at line 246 of file scoped_safearray_unittest.cc.

246 {
247 ScopedSafearray scoped_safe_array;
248 PopulateScopedSafearrayOfInts(scoped_safe_array);
249
250 std::optional<ScopedSafearray::LockScope<VT_I4>> lock_scope =
251 scoped_safe_array.CreateLockScope<VT_I4>();
252
253 std::vector<int> unpacked_vector(lock_scope->begin(), lock_scope->end());
254 ASSERT_EQ(unpacked_vector.size(), kInputValues.size());
255 for (size_t i = 0; i < kInputValues.size(); ++i)
256 EXPECT_EQ(unpacked_vector[i], kInputValues[i]);
257}

◆ TEST() [16/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayLockScopeMoveAssignOperator   
)

Definition at line 192 of file scoped_safearray_unittest.cc.

192 {
193 ScopedSafearray scoped_safe_array;
194 PopulateScopedSafearrayOfInts(scoped_safe_array);
195
196 std::optional<ScopedSafearray::LockScope<VT_I4>> first =
197 scoped_safe_array.CreateLockScope<VT_I4>();
198 ASSERT_TRUE(first.has_value());
199 EXPECT_EQ(first->Type(), VT_I4);
200 EXPECT_EQ(first->size(), kInputValues.size());
201
203 second = std::move(*first);
204 EXPECT_EQ(first->Type(), VT_EMPTY);
205 EXPECT_EQ(first->size(), 0U);
206 EXPECT_EQ(second.Type(), VT_I4);
207 EXPECT_EQ(second.size(), kInputValues.size());
208
209 // Indirectly move |second| into itself.
210 ScopedSafearray::LockScope<VT_I4>& reference_to_second = second;
211 EXPECT_DCHECK_DEATH(second = std::move(reference_to_second));
212}

◆ TEST() [17/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayLockScopeMoveConstructor   
)

Definition at line 175 of file scoped_safearray_unittest.cc.

175 {
176 ScopedSafearray scoped_safe_array;
177 PopulateScopedSafearrayOfInts(scoped_safe_array);
178
179 std::optional<ScopedSafearray::LockScope<VT_I4>> first =
180 scoped_safe_array.CreateLockScope<VT_I4>();
181 ASSERT_TRUE(first.has_value());
182 EXPECT_EQ(first->Type(), VT_I4);
183 EXPECT_EQ(first->size(), kInputValues.size());
184
185 ScopedSafearray::LockScope<VT_I4> second(std::move(*first));
186 EXPECT_EQ(first->Type(), VT_EMPTY);
187 EXPECT_EQ(first->size(), 0U);
188 EXPECT_EQ(second.Type(), VT_I4);
189 EXPECT_EQ(second.size(), kInputValues.size());
190}

◆ TEST() [18/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayLockScopeRandomAccess   
)

Definition at line 231 of file scoped_safearray_unittest.cc.

231 {
232 ScopedSafearray scoped_safe_array;
233 PopulateScopedSafearrayOfInts(scoped_safe_array);
234
235 std::optional<ScopedSafearray::LockScope<VT_I4>> lock_scope =
236 scoped_safe_array.CreateLockScope<VT_I4>();
237 ASSERT_TRUE(lock_scope.has_value());
238 EXPECT_EQ(lock_scope->Type(), VT_I4);
239 EXPECT_EQ(lock_scope->size(), kInputValues.size());
240 for (size_t i = 0; i < kInputValues.size(); ++i) {
241 EXPECT_EQ(lock_scope->at(i), kInputValues[i]);
242 EXPECT_EQ((*lock_scope)[i], kInputValues[i]);
243 }
244}

◆ TEST() [19/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayLockScopeTypeMismatch   
)

Definition at line 214 of file scoped_safearray_unittest.cc.

214 {
215 ScopedSafearray scoped_safe_array;
216 PopulateScopedSafearrayOfInts(scoped_safe_array);
217
218 {
219 std::optional<ScopedSafearray::LockScope<VT_BSTR>> invalid_lock_scope =
220 scoped_safe_array.CreateLockScope<VT_BSTR>();
221 EXPECT_FALSE(invalid_lock_scope.has_value());
222 }
223
224 {
225 std::optional<ScopedSafearray::LockScope<VT_UI4>> invalid_lock_scope =
226 scoped_safe_array.CreateLockScope<VT_UI4>();
227 EXPECT_FALSE(invalid_lock_scope.has_value());
228 }
229}

◆ TEST() [20/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayMethods   
)

Definition at line 40 of file scoped_safearray_unittest.cc.

40 {
41 ScopedSafearray empty_safe_array;
42 EXPECT_EQ(empty_safe_array.Get(), nullptr);
43 EXPECT_EQ(empty_safe_array.Release(), nullptr);
44 EXPECT_NE(empty_safe_array.Receive(), nullptr);
45
46 SAFEARRAY* safe_array = SafeArrayCreateVector(
47 VT_R8 /* element type */, 0 /* lower bound */, 4 /* elements */);
48 ScopedSafearray scoped_safe_array(safe_array);
49 EXPECT_EQ(scoped_safe_array.Get(), safe_array);
50 EXPECT_EQ(scoped_safe_array.Release(), safe_array);
51 EXPECT_NE(scoped_safe_array.Receive(), nullptr);
52
53 // The Release() call should have set the internal pointer to nullptr
54 EXPECT_EQ(scoped_safe_array.Get(), nullptr);
55
56 scoped_safe_array.Reset(safe_array);
57 EXPECT_EQ(scoped_safe_array.Get(), safe_array);
58
59 ScopedSafearray moved_safe_array(std::move(scoped_safe_array));
60 EXPECT_EQ(moved_safe_array.Get(), safe_array);
61 EXPECT_EQ(moved_safe_array.Release(), safe_array);
62 EXPECT_NE(moved_safe_array.Receive(), nullptr);
63
64 // std::move should have cleared the values of scoped_safe_array
65 EXPECT_EQ(scoped_safe_array.Get(), nullptr);
66 EXPECT_EQ(scoped_safe_array.Release(), nullptr);
67 EXPECT_NE(scoped_safe_array.Receive(), nullptr);
68
69 scoped_safe_array.Reset(safe_array);
70 EXPECT_EQ(scoped_safe_array.Get(), safe_array);
71
72 ScopedSafearray assigment_moved_safe_array = std::move(scoped_safe_array);
73 EXPECT_EQ(assigment_moved_safe_array.Get(), safe_array);
74 EXPECT_EQ(assigment_moved_safe_array.Release(), safe_array);
75 EXPECT_NE(assigment_moved_safe_array.Receive(), nullptr);
76
77 // The move-assign operator= should have cleared the values of
78 // scoped_safe_array
79 EXPECT_EQ(scoped_safe_array.Get(), nullptr);
80 EXPECT_EQ(scoped_safe_array.Release(), nullptr);
81 EXPECT_NE(scoped_safe_array.Receive(), nullptr);
82
83 // Calling Receive() will free the existing reference
84 ScopedSafearray safe_array_received(SafeArrayCreateVector(
85 VT_R8 /* element type */, 0 /* lower bound */, 4 /* elements */));
86 EXPECT_NE(safe_array_received.Receive(), nullptr);
87 EXPECT_EQ(safe_array_received.Get(), nullptr);
88}

◆ TEST() [21/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayMoveAssignOperator   
)

Definition at line 102 of file scoped_safearray_unittest.cc.

102 {
103 ScopedSafearray first, second;
104 PopulateScopedSafearrayOfInts(first);
105 EXPECT_NE(first.Get(), nullptr);
106 EXPECT_EQ(first.GetCount(), kInputValues.size());
107
108 SAFEARRAY* safearray = first.Get();
109 second = std::move(first);
110 EXPECT_EQ(first.Get(), nullptr);
111 EXPECT_EQ(second.Get(), safearray);
112
113 // Indirectly move |second| into itself.
114 ScopedSafearray& reference_to_second = second;
115 second = std::move(reference_to_second);
116 EXPECT_EQ(second.GetCount(), kInputValues.size());
117 EXPECT_EQ(second.Get(), safearray);
118}

◆ TEST() [22/130]

base::win::TEST ( ScopedSafearrayTest  ,
ScopedSafearrayMoveConstructor   
)

Definition at line 90 of file scoped_safearray_unittest.cc.

90 {
91 ScopedSafearray first;
92 PopulateScopedSafearrayOfInts(first);
93 EXPECT_NE(first.Get(), nullptr);
94 EXPECT_EQ(first.GetCount(), kInputValues.size());
95
96 SAFEARRAY* safearray = first.Get();
97 ScopedSafearray second(std::move(first));
98 EXPECT_EQ(first.Get(), nullptr);
99 EXPECT_EQ(second.Get(), safearray);
100}

◆ TEST() [23/130]

base::win::TEST ( ScopedVariant  ,
ScopedComIDispatchConstructor   
)

Definition at line 265 of file scoped_variant_unittest.cc.

265 {
266 Microsoft::WRL::ComPtr<IDispatch> dispatch_stub =
267 Microsoft::WRL::Make<DispatchStub>();
268 {
269 ScopedVariant var(dispatch_stub.Get());
270 ExpectVariantType(VT_DISPATCH, var);
271 EXPECT_EQ(dispatch_stub.Get(), V_DISPATCH(var.ptr()));
272 ExpectRefCount(2U, dispatch_stub.Get());
273 }
274 ExpectRefCount(1U, dispatch_stub.Get());
275}

◆ TEST() [24/130]

base::win::TEST ( ScopedVariant  ,
ScopedComIDispatchCopy   
)

Definition at line 292 of file scoped_variant_unittest.cc.

292 {
293 Microsoft::WRL::ComPtr<IDispatch> dispatch_stub =
294 Microsoft::WRL::Make<DispatchStub>();
295 {
296 ScopedVariant var1(dispatch_stub.Get());
297 ExpectRefCount(2U, dispatch_stub.Get());
298 ScopedVariant var2(static_cast<const VARIANT&>(var1));
299 ExpectRefCount(3U, dispatch_stub.Get());
300 ScopedVariant var3;
301 var3 = static_cast<const VARIANT&>(var2);
302 ExpectRefCount(4U, dispatch_stub.Get());
303 }
304 ExpectRefCount(1U, dispatch_stub.Get());
305}

◆ TEST() [25/130]

base::win::TEST ( ScopedVariant  ,
ScopedComIDispatchMove   
)

Definition at line 277 of file scoped_variant_unittest.cc.

277 {
278 Microsoft::WRL::ComPtr<IDispatch> dispatch_stub =
279 Microsoft::WRL::Make<DispatchStub>();
280 {
281 ScopedVariant var1(dispatch_stub.Get());
282 ExpectRefCount(2U, dispatch_stub.Get());
283 ScopedVariant var2(std::move(var1));
284 ExpectRefCount(2U, dispatch_stub.Get());
285 ScopedVariant var3;
286 var3 = std::move(var2);
287 ExpectRefCount(2U, dispatch_stub.Get());
288 }
289 ExpectRefCount(1U, dispatch_stub.Get());
290}

◆ TEST() [26/130]

base::win::TEST ( ScopedVariant  ,
ScopedComIUnknownConstructor   
)

Definition at line 307 of file scoped_variant_unittest.cc.

307 {
308 Microsoft::WRL::ComPtr<IUnknown> unknown_stub =
309 Microsoft::WRL::Make<DispatchStub>();
310 {
311 ScopedVariant unk_var(unknown_stub.Get());
312 ExpectVariantType(VT_UNKNOWN, unk_var);
313 EXPECT_EQ(unknown_stub.Get(), V_UNKNOWN(unk_var.ptr()));
314 ExpectRefCount(2U, unknown_stub.Get());
315 }
316 ExpectRefCount(1U, unknown_stub.Get());
317}

◆ TEST() [27/130]

base::win::TEST ( ScopedVariant  ,
ScopedComIUnknownWithRawVariant   
)

Definition at line 319 of file scoped_variant_unittest.cc.

319 {
320 ScopedVariant var;
321 Microsoft::WRL::ComPtr<IUnknown> unknown_stub =
322 Microsoft::WRL::Make<DispatchStub>();
323 VARIANT raw;
324 raw.vt = VT_UNKNOWN;
325 raw.punkVal = unknown_stub.Get();
326 ExpectRefCount(1U, unknown_stub.Get());
327 var.Set(raw);
328 ExpectRefCount(2U, unknown_stub.Get());
329 var.Reset();
330 ExpectRefCount(1U, unknown_stub.Get());
331}
void Set(const wchar_t *str)
void Reset(const VARIANT &var=kEmptyVariant)

◆ TEST() [28/130]

base::win::TEST ( ScopedVariant  ,
SetNullSafeArray   
)

Definition at line 346 of file scoped_variant_unittest.cc.

346 {
347 ScopedVariant var;
348 var.Set(static_cast<SAFEARRAY*>(nullptr));
349 ExpectVariantType(VT_EMPTY, var);
350}

◆ TEST() [29/130]

base::win::TEST ( ScopedVariant  ,
SetSafeArray   
)

Definition at line 333 of file scoped_variant_unittest.cc.

333 {
334 SAFEARRAY* sa = ::SafeArrayCreateVector(VT_UI1, 0, 100);
335 ASSERT_TRUE(sa);
336
337 ScopedVariant var;
338 var.Set(sa);
339 EXPECT_TRUE(ScopedVariant::IsLeakableVarType(var.type()));
340 ExpectVariantType(static_cast<VARENUM>(VT_ARRAY | VT_UI1), var);
341 EXPECT_EQ(sa, V_ARRAY(var.ptr()));
342 // The array is destroyed in the destructor of var.
343 sa = nullptr;
344}

◆ TEST() [30/130]

base::win::TEST ( ScopedVariantTest  ,
CompareBstr   
)

Definition at line 104 of file scoped_variant_unittest.cc.

104 {
105 ScopedVariant var_bstr1;
106 InitializeVariantWithBstr(var_bstr1.Receive());
107 ScopedVariant var_bstr2(V_BSTR(var_bstr1.ptr()));
108 EXPECT_EQ(0, var_bstr1.Compare(var_bstr2));
109
110 var_bstr2.Reset();
111 EXPECT_NE(0, var_bstr1.Compare(var_bstr2));
112}
int Compare(const VARIANT &other, bool ignore_case=false) const

◆ TEST() [31/130]

base::win::TEST ( ScopedVariantTest  ,
ConstructBstr   
)

Definition at line 54 of file scoped_variant_unittest.cc.

54 {
55 ScopedVariant var(kTestString);
56 ExpectVariantType(VT_BSTR, var);
57 EXPECT_STREQ(kTestString, V_BSTR(var.ptr()));
58}

◆ TEST() [32/130]

base::win::TEST ( ScopedVariantTest  ,
Empty   
)

Definition at line 49 of file scoped_variant_unittest.cc.

49 {
50 ScopedVariant var;
51 ExpectVariantType(VT_EMPTY, var);
52}

◆ TEST() [33/130]

base::win::TEST ( ScopedVariantTest  ,
ReceiveAndCopyBstr   
)

Definition at line 114 of file scoped_variant_unittest.cc.

114 {
115 ScopedVariant var_bstr1;
116 InitializeVariantWithBstr(var_bstr1.Receive());
117 ScopedVariant var_bstr2;
118 var_bstr2.Reset(var_bstr1.Copy());
119 EXPECT_EQ(0, var_bstr1.Compare(var_bstr2));
120}

◆ TEST() [34/130]

base::win::TEST ( ScopedVariantTest  ,
ReleaseBstr   
)

Definition at line 67 of file scoped_variant_unittest.cc.

67 {
68 ScopedVariant var;
69 var.Set(kTestString);
70 VARIANT released_variant = var.Release();
71 ExpectVariantType(VT_EMPTY, var);
72 EXPECT_EQ(VT_BSTR, V_VT(&released_variant));
73 EXPECT_STREQ(kTestString, V_BSTR(&released_variant));
74 ::VariantClear(&released_variant);
75}

◆ TEST() [35/130]

base::win::TEST ( ScopedVariantTest  ,
ResetToEmptyBstr   
)

Definition at line 77 of file scoped_variant_unittest.cc.

77 {
78 ScopedVariant var(kTestString);
79 ExpectVariantType(VT_BSTR, var);
80 var.Reset();
81 ExpectVariantType(VT_EMPTY, var);
82}

◆ TEST() [36/130]

base::win::TEST ( ScopedVariantTest  ,
SetBooleanFalse   
)

Definition at line 218 of file scoped_variant_unittest.cc.

218 {
219 ScopedVariant var;
220 var.Set(false);
221 ExpectVariantType(VT_BOOL, var);
222 EXPECT_EQ(VARIANT_FALSE, V_BOOL(var.ptr()));
223}

◆ TEST() [37/130]

base::win::TEST ( ScopedVariantTest  ,
SetBooleanTrue   
)

Definition at line 211 of file scoped_variant_unittest.cc.

211 {
212 ScopedVariant var;
213 var.Set(true);
214 ExpectVariantType(VT_BOOL, var);
215 EXPECT_EQ(VARIANT_TRUE, V_BOOL(var.ptr()));
216}

◆ TEST() [38/130]

base::win::TEST ( ScopedVariantTest  ,
SetBstr   
)

Definition at line 60 of file scoped_variant_unittest.cc.

60 {
61 ScopedVariant var;
62 var.Set(kTestString);
63 ExpectVariantType(VT_BSTR, var);
64 EXPECT_STREQ(kTestString, V_BSTR(var.ptr()));
65}

◆ TEST() [39/130]

base::win::TEST ( ScopedVariantTest  ,
SetBstrFromBstrVariant   
)

Definition at line 122 of file scoped_variant_unittest.cc.

122 {
123 ScopedVariant var_bstr1;
124 InitializeVariantWithBstr(var_bstr1.Receive());
125 ScopedVariant var_bstr2;
126 var_bstr2.Set(V_BSTR(var_bstr1.ptr()));
127 EXPECT_EQ(0, var_bstr1.Compare(var_bstr2));
128}

◆ TEST() [40/130]

base::win::TEST ( ScopedVariantTest  ,
SetComIDispatch   
)

Definition at line 225 of file scoped_variant_unittest.cc.

225 {
226 ScopedVariant var;
227 Microsoft::WRL::ComPtr<IDispatch> dispatch_stub =
228 Microsoft::WRL::Make<DispatchStub>();
229 ExpectRefCount(1U, dispatch_stub.Get());
230 var.Set(dispatch_stub.Get());
231 ExpectVariantType(VT_DISPATCH, var);
232 EXPECT_EQ(dispatch_stub.Get(), V_DISPATCH(var.ptr()));
233 ExpectRefCount(2U, dispatch_stub.Get());
234 var.Reset();
235 ExpectRefCount(1U, dispatch_stub.Get());
236}

◆ TEST() [41/130]

base::win::TEST ( ScopedVariantTest  ,
SetComIUnknown   
)

Definition at line 245 of file scoped_variant_unittest.cc.

245 {
246 ScopedVariant var;
247 Microsoft::WRL::ComPtr<IUnknown> unknown_stub =
248 Microsoft::WRL::Make<DispatchStub>();
249 ExpectRefCount(1U, unknown_stub.Get());
250 var.Set(unknown_stub.Get());
251 ExpectVariantType(VT_UNKNOWN, var);
252 EXPECT_EQ(unknown_stub.Get(), V_UNKNOWN(var.ptr()));
253 ExpectRefCount(2U, unknown_stub.Get());
254 var.Reset();
255 ExpectRefCount(1U, unknown_stub.Get());
256}

◆ TEST() [42/130]

base::win::TEST ( ScopedVariantTest  ,
SetComNullIDispatch   
)

Definition at line 238 of file scoped_variant_unittest.cc.

238 {
239 ScopedVariant var;
240 var.Set(static_cast<IDispatch*>(nullptr));
241 ExpectVariantType(VT_DISPATCH, var);
242 EXPECT_EQ(nullptr, V_DISPATCH(var.ptr()));
243}

◆ TEST() [43/130]

base::win::TEST ( ScopedVariantTest  ,
SetComNullIUnknown   
)

Definition at line 258 of file scoped_variant_unittest.cc.

258 {
259 ScopedVariant var;
260 var.Set(static_cast<IUnknown*>(nullptr));
261 ExpectVariantType(VT_UNKNOWN, var);
262 EXPECT_EQ(nullptr, V_UNKNOWN(var.ptr()));
263}

◆ TEST() [44/130]

base::win::TEST ( ScopedVariantTest  ,
SetDate   
)

Definition at line 130 of file scoped_variant_unittest.cc.

130 {
131 ScopedVariant var;
132 SYSTEMTIME sys_time;
133 ::GetSystemTime(&sys_time);
134 DATE date;
135 ::SystemTimeToVariantTime(&sys_time, &date);
136 var.SetDate(date);
137 ExpectVariantType(VT_DATE, var);
138 EXPECT_EQ(date, V_DATE(var.ptr()));
139}

◆ TEST() [45/130]

base::win::TEST ( ScopedVariantTest  ,
SetReal4Byte   
)

Definition at line 197 of file scoped_variant_unittest.cc.

197 {
198 ScopedVariant var;
199 var.Set(123.123f);
200 ExpectVariantType(VT_R4, var);
201 EXPECT_EQ(123.123f, V_R4(var.ptr()));
202}

◆ TEST() [46/130]

base::win::TEST ( ScopedVariantTest  ,
SetReal8Byte   
)

Definition at line 204 of file scoped_variant_unittest.cc.

204 {
205 ScopedVariant var;
206 var.Set(static_cast<double>(123.123));
207 ExpectVariantType(VT_R8, var);
208 EXPECT_EQ(123.123, V_R8(var.ptr()));
209}

◆ TEST() [47/130]

base::win::TEST ( ScopedVariantTest  ,
SetSigned1Byte   
)

Definition at line 141 of file scoped_variant_unittest.cc.

141 {
142 ScopedVariant var;
143 var.Set(static_cast<int8_t>('v'));
144 ExpectVariantType(VT_I1, var);
145 EXPECT_EQ('v', V_I1(var.ptr()));
146}

◆ TEST() [48/130]

base::win::TEST ( ScopedVariantTest  ,
SetSigned2Byte   
)

Definition at line 148 of file scoped_variant_unittest.cc.

148 {
149 ScopedVariant var;
150 var.Set(static_cast<short>(123));
151 ExpectVariantType(VT_I2, var);
152 EXPECT_EQ(123, V_I2(var.ptr()));
153}

◆ TEST() [49/130]

base::win::TEST ( ScopedVariantTest  ,
SetSigned4Byte   
)

Definition at line 155 of file scoped_variant_unittest.cc.

155 {
156 ScopedVariant var;
157 var.Set(123);
158 ExpectVariantType(VT_I4, var);
159 EXPECT_EQ(123, V_I4(var.ptr()));
160}

◆ TEST() [50/130]

base::win::TEST ( ScopedVariantTest  ,
SetSigned8Byte   
)

Definition at line 162 of file scoped_variant_unittest.cc.

162 {
163 ScopedVariant var;
164 var.Set(static_cast<int64_t>(123));
165 ExpectVariantType(VT_I8, var);
166 EXPECT_EQ(123, V_I8(var.ptr()));
167}

◆ TEST() [51/130]

base::win::TEST ( ScopedVariantTest  ,
SetUnsigned1Byte   
)

Definition at line 169 of file scoped_variant_unittest.cc.

169 {
170 ScopedVariant var;
171 var.Set(static_cast<uint8_t>(123));
172 ExpectVariantType(VT_UI1, var);
173 EXPECT_EQ(123u, V_UI1(var.ptr()));
174}

◆ TEST() [52/130]

base::win::TEST ( ScopedVariantTest  ,
SetUnsigned2Byte   
)

Definition at line 176 of file scoped_variant_unittest.cc.

176 {
177 ScopedVariant var;
178 var.Set(static_cast<unsigned short>(123));
179 ExpectVariantType(VT_UI2, var);
180 EXPECT_EQ(123u, V_UI2(var.ptr()));
181}

◆ TEST() [53/130]

base::win::TEST ( ScopedVariantTest  ,
SetUnsigned4Byte   
)

Definition at line 183 of file scoped_variant_unittest.cc.

183 {
184 ScopedVariant var;
185 var.Set(static_cast<uint32_t>(123));
186 ExpectVariantType(VT_UI4, var);
187 EXPECT_EQ(123u, V_UI4(var.ptr()));
188}

◆ TEST() [54/130]

base::win::TEST ( ScopedVariantTest  ,
SetUnsigned8Byte   
)

Definition at line 190 of file scoped_variant_unittest.cc.

190 {
191 ScopedVariant var;
192 var.Set(static_cast<uint64_t>(123));
193 ExpectVariantType(VT_UI8, var);
194 EXPECT_EQ(123u, V_UI8(var.ptr()));
195}

◆ TEST() [55/130]

base::win::TEST ( ScopedVariantTest  ,
SwapBstr   
)

Definition at line 95 of file scoped_variant_unittest.cc.

95 {
96 ScopedVariant from(kTestString);
98 to.Swap(from);
99 ExpectVariantType(VT_EMPTY, from);
100 ExpectVariantType(VT_BSTR, to);
101 EXPECT_STREQ(kTestString, V_BSTR(to.ptr()));
102}
void Swap(ScopedVariant &var)

◆ TEST() [56/130]

base::win::TEST ( ScopedVariantTest  ,
TakeOwnershipBstr   
)

Definition at line 84 of file scoped_variant_unittest.cc.

84 {
85 VARIANT bstr_variant;
86 bstr_variant.vt = VT_BSTR;
87 bstr_variant.bstrVal = ::SysAllocString(kTestString);
88
89 ScopedVariant var;
90 var.Reset(bstr_variant);
91 ExpectVariantType(VT_BSTR, var);
92 EXPECT_EQ(bstr_variant.bstrVal, V_BSTR(var.ptr()));
93}

◆ TEST() [57/130]

base::win::TEST ( VariantVectorTest  ,
CompareSafearray   
)

Definition at line 1389 of file variant_vector_unittest.cc.

1389 {
1390 VariantVector vector;
1391 vector.Insert<VT_I4>(123);
1392 vector.Insert<VT_I4>(456);
1393 EXPECT_EQ(vector.Type(), VT_I4);
1394 EXPECT_EQ(vector.Size(), 2U);
1395
1396 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1397 EXPECT_EQ(variant.type(), VT_ARRAY | VT_I4);
1398 EXPECT_EQ(vector.Type(), VT_EMPTY);
1399 EXPECT_EQ(vector.Size(), 0U);
1400
1401 // Because |vector| is now empty, it will compare as less-than the array.
1402 EXPECT_EQ(vector.Compare(V_ARRAY(variant.ptr())), -1);
1403 EXPECT_EQ(vector.Compare(variant), -1);
1404
1405 vector.Insert<VT_I4>(123);
1406 EXPECT_EQ(vector.Type(), VT_I4);
1407 EXPECT_EQ(vector.Size(), 1U);
1408 // |vector| has fewer elements than |variant|.
1409 EXPECT_EQ(vector.Compare(V_ARRAY(variant.ptr())), -1);
1410 EXPECT_EQ(vector.Compare(variant), -1);
1411
1412 vector.Insert<VT_I4>(456);
1413 EXPECT_EQ(vector.Type(), VT_I4);
1414 EXPECT_EQ(vector.Size(), 2U);
1415 // |vector| is now equal to |variant|.
1416 EXPECT_EQ(vector.Compare(V_ARRAY(variant.ptr())), 0);
1417 EXPECT_EQ(vector.Compare(variant), 0);
1418
1419 vector.Insert<VT_I4>(789);
1420 EXPECT_EQ(vector.Type(), VT_I4);
1421 EXPECT_EQ(vector.Size(), 3U);
1422 // |vector| contains |variant| but has more elements so
1423 // |vector| is now greater-than |variant|.
1424 EXPECT_EQ(vector.Compare(V_ARRAY(variant.ptr())), 1);
1425 EXPECT_EQ(vector.Compare(variant), 1);
1426
1427 vector.Reset();
1428 vector.Insert<VT_I4>(456);
1429 EXPECT_EQ(vector.Type(), VT_I4);
1430 EXPECT_EQ(vector.Size(), 1U);
1431 // |vector| has fewer elements than |variant|, but the first element in
1432 // |vector| compares as greater-than the first element in |variant|.
1433 EXPECT_EQ(vector.Compare(V_ARRAY(variant.ptr())), 1);
1434 EXPECT_EQ(vector.Compare(variant), 1);
1435
1436 vector.Reset();
1437 vector.Insert<VT_R8>(0.0);
1438 vector.Insert<VT_R8>(0.0);
1439 EXPECT_EQ(vector.Type(), VT_R8);
1440 // Because the types do not match and VT_R8 is greater-than VT_I4,
1441 // |vector| compares as greater-than |variant|, even though the values
1442 // in |vector| are less-than the values in |variant|.
1443 EXPECT_GT(VT_R8, VT_I4);
1444 EXPECT_EQ(vector.Compare(V_ARRAY(variant.ptr())), 1);
1445 EXPECT_EQ(vector.Compare(variant), 1);
1446
1447 vector.Reset();
1448 vector.Insert<VT_I2>(1000);
1449 vector.Insert<VT_I2>(1000);
1450 EXPECT_EQ(vector.Type(), VT_I2);
1451 // Because the types do not match and VT_I2 is less-than VT_I4,
1452 // |vector| compares as less-than |variant|, even though the values
1453 // in |vector| are greater-than the values in |variant|.
1454 EXPECT_LT(VT_I2, VT_I4);
1455 EXPECT_EQ(vector.Compare(V_ARRAY(variant.ptr())), -1);
1456 EXPECT_EQ(vector.Compare(variant), -1);
1457}
void Insert(typename internal::VariantUtil< ExpectedVartype >::Type value)
int Compare(const VARIANT &other, bool ignore_case=false) const

◆ TEST() [58/130]

base::win::TEST ( VariantVectorTest  ,
CompareVariant   
)

Definition at line 1351 of file variant_vector_unittest.cc.

1351 {
1352 VariantVector vector;
1353 ScopedVariant variant;
1354 EXPECT_EQ(vector.Compare(variant), 0);
1355
1356 vector.Insert<VT_I4>(123);
1357 EXPECT_EQ(vector.Type(), VT_I4);
1358 EXPECT_EQ(vector.Size(), 1U);
1359
1360 variant.Set(123);
1361 EXPECT_EQ(vector.Compare(variant), 0);
1362 variant.Set(4);
1363 EXPECT_EQ(vector.Compare(variant), 1);
1364 variant.Set(567);
1365 EXPECT_EQ(vector.Compare(variant), -1);
1366 // Because the types do not match and VT_I4 is less-than VT_R8,
1367 // |vector| compares as less-than |variant|, even though the value
1368 // in |vector| is greater.
1369 variant.Set(1.0);
1370 EXPECT_EQ(variant.type(), VT_R8);
1371 EXPECT_LT(vector.Type(), variant.type());
1372 EXPECT_EQ(vector.Compare(variant), -1);
1373
1374 vector.Insert<VT_I4>(456);
1375 EXPECT_EQ(vector.Size(), 2U);
1376
1377 // The first element of |vector| is equal to |variant|, but |vector|
1378 // has more than one element so it is greater-than |variant|.
1379 variant.Set(123);
1380 EXPECT_EQ(vector.Compare(variant), 1);
1381 // The first element of |vector| is greater-than |variant|.
1382 variant.Set(5);
1383 EXPECT_EQ(vector.Compare(variant), 1);
1384 // The first element of |vector| is less-than |variant|.
1385 variant.Set(1000);
1386 EXPECT_EQ(vector.Compare(variant), -1);
1387}

◆ TEST() [59/130]

base::win::TEST ( VariantVectorTest  ,
CompareVariantVector   
)

Definition at line 1459 of file variant_vector_unittest.cc.

1459 {
1460 VariantVector vector1, vector2;
1461 EXPECT_EQ(vector1.Compare(vector2), 0);
1462 EXPECT_EQ(vector1, vector2);
1463
1464 vector1.Insert<VT_I4>(1);
1465 EXPECT_EQ(vector1.Compare(vector2), 1);
1466 EXPECT_EQ(vector2.Compare(vector1), -1);
1467 EXPECT_NE(vector1, vector2);
1468
1469 vector2.Insert<VT_I4>(1);
1470 EXPECT_EQ(vector1.Compare(vector2), 0);
1471 EXPECT_EQ(vector2.Compare(vector1), 0);
1472 EXPECT_EQ(vector1, vector2);
1473
1474 vector1.Insert<VT_I4>(1);
1475 EXPECT_EQ(vector1.Compare(vector2), 1);
1476 EXPECT_EQ(vector2.Compare(vector1), -1);
1477 EXPECT_NE(vector1, vector2);
1478
1479 vector2.Insert<VT_I4>(2);
1480 EXPECT_EQ(vector1.Compare(vector2), -1);
1481 EXPECT_EQ(vector2.Compare(vector1), 1);
1482 EXPECT_NE(vector1, vector2);
1483
1484 vector1.Reset();
1485 vector1.Insert<VT_I4>(10);
1486 vector2.Reset();
1487 vector2.Insert<VT_R8>(5.0);
1488 // Because the types do not match and VT_I4 is less-than VT_R8,
1489 // |vector1| compares as less-than |vector2|, even though the value
1490 // in |vector1| is greater.
1491 EXPECT_LT(vector1.Type(), vector2.Type());
1492 EXPECT_EQ(vector1.Compare(vector2), -1);
1493 EXPECT_EQ(vector2.Compare(vector1), 1);
1494 EXPECT_NE(vector1, vector2);
1495}

◆ TEST() [60/130]

base::win::TEST ( VariantVectorTest  ,
InitiallyEmpty   
)

Definition at line 23 of file variant_vector_unittest.cc.

23 {
24 VariantVector vector;
25 EXPECT_EQ(vector.Type(), VT_EMPTY);
26 EXPECT_EQ(vector.Size(), 0U);
27 EXPECT_TRUE(vector.Empty());
28}

◆ TEST() [61/130]

base::win::TEST ( VariantVectorTest  ,
Insert   
)

Definition at line 74 of file variant_vector_unittest.cc.

74 {
75 VariantVector vector;
76 vector.Insert<VT_I4>(123);
77 EXPECT_EQ(vector.Type(), VT_I4);
78 // The first insert sets the type to VT_I4, and attempting to insert
79 // unrelated types will silently fail in release builds but DCHECKs
80 // in debug builds.
81 EXPECT_DCHECK_DEATH(vector.Insert<VT_UI4>(1U));
82 EXPECT_DCHECK_DEATH(vector.Insert<VT_R8>(100.0));
83 EXPECT_EQ(vector.Type(), VT_I4);
84 EXPECT_EQ(vector.Size(), 1U);
85 EXPECT_FALSE(vector.Empty());
86}

◆ TEST() [62/130]

base::win::TEST ( VariantVectorTest  ,
InsertCannotDowncastUnknownToDispatch   
)

Definition at line 102 of file variant_vector_unittest.cc.

102 {
103 Microsoft::WRL::ComPtr<IDispatch> dispatch =
104 Microsoft::WRL::Make<DispatchStub>();
105 Microsoft::WRL::ComPtr<IDispatch> unknown;
106 dispatch.CopyTo(&unknown);
107
108 VariantVector vector;
109 vector.Insert<VT_DISPATCH>(dispatch.Get());
110 // The first insert sets the type to VT_DISPATCH, and attempting to
111 // explicitly insert VT_UNKNOWN will silently fail in release builds
112 // but DCHECKs in debug builds.
113 EXPECT_DCHECK_DEATH(vector.Insert<VT_UNKNOWN>(unknown.Get()));
114 EXPECT_DCHECK_DEATH(vector.Insert<VT_UNKNOWN>(dispatch.Get()));
115 EXPECT_EQ(vector.Type(), VT_DISPATCH);
116 EXPECT_EQ(vector.Size(), 1U);
117}

◆ TEST() [63/130]

base::win::TEST ( VariantVectorTest  ,
InsertCanUpcastDispatchToUnknown   
)

Definition at line 88 of file variant_vector_unittest.cc.

88 {
89 Microsoft::WRL::ComPtr<IDispatch> dispatch =
90 Microsoft::WRL::Make<DispatchStub>();
91 Microsoft::WRL::ComPtr<IDispatch> unknown;
92 dispatch.CopyTo(&unknown);
93
94 VariantVector vector;
95 vector.Insert<VT_UNKNOWN>(unknown.Get());
96 vector.Insert<VT_UNKNOWN>(dispatch.Get());
97 vector.Insert<VT_DISPATCH>(dispatch.Get());
98 EXPECT_EQ(vector.Type(), VT_UNKNOWN);
99 EXPECT_EQ(vector.Size(), 3U);
100}

◆ TEST() [64/130]

base::win::TEST ( VariantVectorTest  ,
MoveAssignOperator   
)

Definition at line 47 of file variant_vector_unittest.cc.

47 {
48 VariantVector vector1, vector2;
49 Microsoft::WRL::ComPtr<IDispatch> dispatch1 =
50 Microsoft::WRL::Make<DispatchStub>();
51 Microsoft::WRL::ComPtr<IDispatch> dispatch2 =
52 Microsoft::WRL::Make<DispatchStub>();
53 vector1.Insert<VT_DISPATCH>(dispatch1.Get());
54 vector2.Insert<VT_UNKNOWN>(dispatch2.Get());
55 EXPECT_EQ(vector1.Type(), VT_DISPATCH);
56 EXPECT_EQ(vector1.Size(), 1U);
57 EXPECT_EQ(vector2.Type(), VT_UNKNOWN);
58 EXPECT_EQ(vector2.Size(), 1U);
59 vector1 = std::move(vector2);
60 EXPECT_EQ(vector1.Type(), VT_UNKNOWN);
61 EXPECT_EQ(vector1.Size(), 1U);
62 EXPECT_EQ(vector2.Type(), VT_EMPTY);
63 EXPECT_EQ(vector2.Size(), 0U);
64 // |dispatch1| should have been released during the move.
65 EXPECT_EQ(dispatch1.Reset(), 0U);
66 // |dispatch2| should have been transferred to |vector1|.
67 EXPECT_EQ(dispatch2.Reset(), 1U);
68
69 // Indirectly move |vector1| into itself.
70 VariantVector& reference_to_vector1 = vector1;
71 EXPECT_DCHECK_DEATH(vector1 = std::move(reference_to_vector1));
72}

◆ TEST() [65/130]

base::win::TEST ( VariantVectorTest  ,
MoveConstructor   
)

Definition at line 30 of file variant_vector_unittest.cc.

30 {
31 VariantVector vector1;
32 Microsoft::WRL::ComPtr<IDispatch> dispatch =
33 Microsoft::WRL::Make<DispatchStub>();
34 vector1.Insert<VT_DISPATCH>(dispatch.Get());
35 EXPECT_EQ(vector1.Type(), VT_DISPATCH);
36 EXPECT_EQ(vector1.Size(), 1U);
37
38 VariantVector vector2(std::move(vector1));
39 EXPECT_EQ(vector1.Type(), VT_EMPTY);
40 EXPECT_EQ(vector1.Size(), 0U);
41 EXPECT_EQ(vector2.Type(), VT_DISPATCH);
42 EXPECT_EQ(vector2.Size(), 1U);
43 // |dispatch| should have been transferred to |vector2|.
44 EXPECT_EQ(dispatch.Reset(), 1U);
45}

◆ TEST() [66/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantEmpty   
)

Definition at line 610 of file variant_vector_unittest.cc.

610 {
611 VariantVector vector;
613 EXPECT_EQ(variant.type(), VT_EMPTY);
614}

◆ TEST() [67/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleBool   
)

Definition at line 958 of file variant_vector_unittest.cc.

958 {
959 constexpr VARTYPE kVariantType = VT_BOOL;
960 VariantVector vector;
961
962 vector.Insert<kVariantType>(true);
963 vector.Insert<kVariantType>(false);
964 vector.Insert<kVariantType>(true);
965 EXPECT_EQ(vector.Type(), kVariantType);
966 EXPECT_EQ(vector.Size(), 3U);
967
969 EXPECT_EQ(vector.Type(), VT_EMPTY);
970 EXPECT_EQ(vector.Size(), 0U);
971 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
972
973 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
974 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
975 safearray.CreateLockScope<kVariantType>();
976 ASSERT_TRUE(lock_scope.has_value());
977 ASSERT_EQ(lock_scope->size(), 3U);
978 EXPECT_EQ(lock_scope->at(0), VARIANT_TRUE);
979 EXPECT_EQ(lock_scope->at(1), VARIANT_FALSE);
980 EXPECT_EQ(lock_scope->at(2), VARIANT_TRUE);
981 safearray.Release();
982}

◆ TEST() [68/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleBstr   
)

Definition at line 1268 of file variant_vector_unittest.cc.

1268 {
1269 constexpr VARTYPE kVariantType = VT_BSTR;
1270 VariantVector vector;
1271 wchar_t some_text[] = L"some text";
1272 wchar_t more_text[] = L"more text";
1273 vector.Insert<kVariantType>(some_text);
1274 vector.Insert<kVariantType>(more_text);
1275 EXPECT_EQ(vector.Type(), kVariantType);
1276 EXPECT_EQ(vector.Size(), 2U);
1277
1278 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1279 EXPECT_EQ(vector.Type(), VT_EMPTY);
1280 EXPECT_EQ(vector.Size(), 0U);
1281 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1282
1283 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1284 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1285 safearray.CreateLockScope<kVariantType>();
1286 ASSERT_TRUE(lock_scope.has_value());
1287 ASSERT_EQ(lock_scope->size(), 2U);
1288 EXPECT_STREQ(lock_scope->at(0), some_text);
1289 EXPECT_STREQ(lock_scope->at(1), more_text);
1290 safearray.Release();
1291}

◆ TEST() [69/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleDate   
)

Definition at line 1240 of file variant_vector_unittest.cc.

1240 {
1241 constexpr VARTYPE kVariantType = VT_DATE;
1242 VariantVector vector;
1243 SYSTEMTIME sys_time;
1244 ::GetSystemTime(&sys_time);
1245 DATE date;
1246 ::SystemTimeToVariantTime(&sys_time, &date);
1247
1248 vector.Insert<kVariantType>(date);
1249 vector.Insert<kVariantType>(date);
1250 EXPECT_EQ(vector.Type(), kVariantType);
1251 EXPECT_EQ(vector.Size(), 2U);
1252
1253 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1254 EXPECT_EQ(vector.Type(), VT_EMPTY);
1255 EXPECT_EQ(vector.Size(), 0U);
1256 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1257
1258 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1259 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1260 safearray.CreateLockScope<kVariantType>();
1261 ASSERT_TRUE(lock_scope.has_value());
1262 ASSERT_EQ(lock_scope->size(), 2U);
1263 EXPECT_EQ(lock_scope->at(0), date);
1264 EXPECT_EQ(lock_scope->at(1), date);
1265 safearray.Release();
1266}

◆ TEST() [70/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleDispatch   
)

Definition at line 1322 of file variant_vector_unittest.cc.

1322 {
1323 constexpr VARTYPE kVariantType = VT_DISPATCH;
1324 VariantVector vector;
1325
1326 Microsoft::WRL::ComPtr<IDispatch> dispatch1 =
1327 Microsoft::WRL::Make<DispatchStub>();
1328 Microsoft::WRL::ComPtr<IDispatch> dispatch2 =
1329 Microsoft::WRL::Make<DispatchStub>();
1330
1331 vector.Insert<kVariantType>(dispatch1.Get());
1332 vector.Insert<kVariantType>(dispatch2.Get());
1333 EXPECT_EQ(vector.Type(), kVariantType);
1334 EXPECT_EQ(vector.Size(), 2U);
1335
1336 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1337 EXPECT_EQ(vector.Type(), VT_EMPTY);
1338 EXPECT_EQ(vector.Size(), 0U);
1339 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1340
1341 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1342 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1343 safearray.CreateLockScope<kVariantType>();
1344 ASSERT_TRUE(lock_scope.has_value());
1345 ASSERT_EQ(lock_scope->size(), 2U);
1346 EXPECT_EQ(lock_scope->at(0), dispatch1.Get());
1347 EXPECT_EQ(lock_scope->at(1), dispatch2.Get());
1348 safearray.Release();
1349}

◆ TEST() [71/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleI1   
)

Definition at line 984 of file variant_vector_unittest.cc.

984 {
985 constexpr VARTYPE kVariantType = VT_I1;
986 VariantVector vector;
987
988 vector.Insert<kVariantType>(34);
989 vector.Insert<kVariantType>(52);
990 vector.Insert<kVariantType>(12);
991 EXPECT_EQ(vector.Type(), kVariantType);
992 EXPECT_EQ(vector.Size(), 3U);
993
995 EXPECT_EQ(vector.Type(), VT_EMPTY);
996 EXPECT_EQ(vector.Size(), 0U);
997 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
998
999 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1000 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1001 safearray.CreateLockScope<kVariantType>();
1002 ASSERT_TRUE(lock_scope.has_value());
1003 ASSERT_EQ(lock_scope->size(), 3U);
1004 EXPECT_EQ(lock_scope->at(0), 34);
1005 EXPECT_EQ(lock_scope->at(1), 52);
1006 EXPECT_EQ(lock_scope->at(2), 12);
1007 safearray.Release();
1008}

◆ TEST() [72/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleI2   
)

Definition at line 1036 of file variant_vector_unittest.cc.

1036 {
1037 constexpr VARTYPE kVariantType = VT_I2;
1038 VariantVector vector;
1039
1040 vector.Insert<kVariantType>(8738);
1041 vector.Insert<kVariantType>(8758);
1042 vector.Insert<kVariantType>(42);
1043 EXPECT_EQ(vector.Type(), kVariantType);
1044 EXPECT_EQ(vector.Size(), 3U);
1045
1046 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1047 EXPECT_EQ(vector.Type(), VT_EMPTY);
1048 EXPECT_EQ(vector.Size(), 0U);
1049 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1050
1051 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1052 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1053 safearray.CreateLockScope<kVariantType>();
1054 ASSERT_TRUE(lock_scope.has_value());
1055 ASSERT_EQ(lock_scope->size(), 3U);
1056 EXPECT_EQ(lock_scope->at(0), 8738);
1057 EXPECT_EQ(lock_scope->at(1), 8758);
1058 EXPECT_EQ(lock_scope->at(2), 42);
1059 safearray.Release();
1060}

◆ TEST() [73/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleI4   
)

Definition at line 1088 of file variant_vector_unittest.cc.

1088 {
1089 constexpr VARTYPE kVariantType = VT_I4;
1090 VariantVector vector;
1091
1092 vector.Insert<kVariantType>(572662306);
1093 vector.Insert<kVariantType>(572662307);
1094 vector.Insert<kVariantType>(572662308);
1095 EXPECT_EQ(vector.Type(), kVariantType);
1096 EXPECT_EQ(vector.Size(), 3U);
1097
1098 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1099 EXPECT_EQ(vector.Type(), VT_EMPTY);
1100 EXPECT_EQ(vector.Size(), 0U);
1101 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1102
1103 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1104 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1105 safearray.CreateLockScope<kVariantType>();
1106 ASSERT_TRUE(lock_scope.has_value());
1107 ASSERT_EQ(lock_scope->size(), 3U);
1108 EXPECT_EQ(lock_scope->at(0), 572662306);
1109 EXPECT_EQ(lock_scope->at(1), 572662307);
1110 EXPECT_EQ(lock_scope->at(2), 572662308);
1111 safearray.Release();
1112}

◆ TEST() [74/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleI8   
)

Definition at line 1140 of file variant_vector_unittest.cc.

1140 {
1141 constexpr VARTYPE kVariantType = VT_I8;
1142 VariantVector vector;
1143
1144 vector.Insert<kVariantType>(2459565876494606882);
1145 vector.Insert<kVariantType>(2459565876494606883);
1146 vector.Insert<kVariantType>(2459565876494606884);
1147 EXPECT_EQ(vector.Type(), kVariantType);
1148 EXPECT_EQ(vector.Size(), 3U);
1149
1150 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1151 EXPECT_EQ(vector.Type(), VT_EMPTY);
1152 EXPECT_EQ(vector.Size(), 0U);
1153 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1154
1155 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1156 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1157 safearray.CreateLockScope<kVariantType>();
1158 ASSERT_TRUE(lock_scope.has_value());
1159 ASSERT_EQ(lock_scope->size(), 3U);
1160 EXPECT_EQ(lock_scope->at(0), 2459565876494606882);
1161 EXPECT_EQ(lock_scope->at(1), 2459565876494606883);
1162 EXPECT_EQ(lock_scope->at(2), 2459565876494606884);
1163 safearray.Release();
1164}

◆ TEST() [75/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleR4   
)

Definition at line 1192 of file variant_vector_unittest.cc.

1192 {
1193 constexpr VARTYPE kVariantType = VT_R4;
1194 VariantVector vector;
1195
1196 vector.Insert<kVariantType>(3.14159f);
1197 vector.Insert<kVariantType>(6.28318f);
1198 EXPECT_EQ(vector.Type(), kVariantType);
1199 EXPECT_EQ(vector.Size(), 2U);
1200
1201 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1202 EXPECT_EQ(vector.Type(), VT_EMPTY);
1203 EXPECT_EQ(vector.Size(), 0U);
1204 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1205
1206 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1207 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1208 safearray.CreateLockScope<kVariantType>();
1209 ASSERT_TRUE(lock_scope.has_value());
1210 ASSERT_EQ(lock_scope->size(), 2U);
1211 EXPECT_EQ(lock_scope->at(0), 3.14159f);
1212 EXPECT_EQ(lock_scope->at(1), 6.28318f);
1213 safearray.Release();
1214}

◆ TEST() [76/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleR8   
)

Definition at line 1216 of file variant_vector_unittest.cc.

1216 {
1217 constexpr VARTYPE kVariantType = VT_R8;
1218 VariantVector vector;
1219
1220 vector.Insert<kVariantType>(6.28318);
1221 vector.Insert<kVariantType>(3.14159);
1222 EXPECT_EQ(vector.Type(), kVariantType);
1223 EXPECT_EQ(vector.Size(), 2U);
1224
1225 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1226 EXPECT_EQ(vector.Type(), VT_EMPTY);
1227 EXPECT_EQ(vector.Size(), 0U);
1228 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1229
1230 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1231 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1232 safearray.CreateLockScope<kVariantType>();
1233 ASSERT_TRUE(lock_scope.has_value());
1234 ASSERT_EQ(lock_scope->size(), 2U);
1235 EXPECT_EQ(lock_scope->at(0), 6.28318);
1236 EXPECT_EQ(lock_scope->at(1), 3.14159);
1237 safearray.Release();
1238}

◆ TEST() [77/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleUI1   
)

Definition at line 1010 of file variant_vector_unittest.cc.

1010 {
1011 constexpr VARTYPE kVariantType = VT_UI1;
1012 VariantVector vector;
1013
1014 vector.Insert<kVariantType>(34U);
1015 vector.Insert<kVariantType>(52U);
1016 vector.Insert<kVariantType>(12U);
1017 EXPECT_EQ(vector.Type(), kVariantType);
1018 EXPECT_EQ(vector.Size(), 3U);
1019
1020 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1021 EXPECT_EQ(vector.Type(), VT_EMPTY);
1022 EXPECT_EQ(vector.Size(), 0U);
1023 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1024
1025 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1026 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1027 safearray.CreateLockScope<kVariantType>();
1028 ASSERT_TRUE(lock_scope.has_value());
1029 ASSERT_EQ(lock_scope->size(), 3U);
1030 EXPECT_EQ(lock_scope->at(0), 34U);
1031 EXPECT_EQ(lock_scope->at(1), 52U);
1032 EXPECT_EQ(lock_scope->at(2), 12U);
1033 safearray.Release();
1034}

◆ TEST() [78/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleUI2   
)

Definition at line 1062 of file variant_vector_unittest.cc.

1062 {
1063 constexpr VARTYPE kVariantType = VT_UI2;
1064 VariantVector vector;
1065
1066 vector.Insert<kVariantType>(8739U);
1067 vector.Insert<kVariantType>(8759U);
1068 vector.Insert<kVariantType>(42U);
1069 EXPECT_EQ(vector.Type(), kVariantType);
1070 EXPECT_EQ(vector.Size(), 3U);
1071
1072 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1073 EXPECT_EQ(vector.Type(), VT_EMPTY);
1074 EXPECT_EQ(vector.Size(), 0U);
1075 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1076
1077 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1078 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1079 safearray.CreateLockScope<kVariantType>();
1080 ASSERT_TRUE(lock_scope.has_value());
1081 ASSERT_EQ(lock_scope->size(), 3U);
1082 EXPECT_EQ(lock_scope->at(0), 8739U);
1083 EXPECT_EQ(lock_scope->at(1), 8759U);
1084 EXPECT_EQ(lock_scope->at(2), 42U);
1085 safearray.Release();
1086}

◆ TEST() [79/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleUI4   
)

Definition at line 1114 of file variant_vector_unittest.cc.

1114 {
1115 constexpr VARTYPE kVariantType = VT_UI4;
1116 VariantVector vector;
1117
1118 vector.Insert<kVariantType>(578662306U);
1119 vector.Insert<kVariantType>(578662307U);
1120 vector.Insert<kVariantType>(578662308U);
1121 EXPECT_EQ(vector.Type(), kVariantType);
1122 EXPECT_EQ(vector.Size(), 3U);
1123
1124 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1125 EXPECT_EQ(vector.Type(), VT_EMPTY);
1126 EXPECT_EQ(vector.Size(), 0U);
1127 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1128
1129 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1130 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1131 safearray.CreateLockScope<kVariantType>();
1132 ASSERT_TRUE(lock_scope.has_value());
1133 ASSERT_EQ(lock_scope->size(), 3U);
1134 EXPECT_EQ(lock_scope->at(0), 578662306U);
1135 EXPECT_EQ(lock_scope->at(1), 578662307U);
1136 EXPECT_EQ(lock_scope->at(2), 578662308U);
1137 safearray.Release();
1138}

◆ TEST() [80/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleUI8   
)

Definition at line 1166 of file variant_vector_unittest.cc.

1166 {
1167 constexpr VARTYPE kVariantType = VT_UI8;
1168 VariantVector vector;
1169
1170 vector.Insert<kVariantType>(2459565876494606883U);
1171 vector.Insert<kVariantType>(2459565876494606884U);
1172 vector.Insert<kVariantType>(2459565876494606885U);
1173 EXPECT_EQ(vector.Type(), kVariantType);
1174 EXPECT_EQ(vector.Size(), 3U);
1175
1176 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1177 EXPECT_EQ(vector.Type(), VT_EMPTY);
1178 EXPECT_EQ(vector.Size(), 0U);
1179 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1180
1181 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1182 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1183 safearray.CreateLockScope<kVariantType>();
1184 ASSERT_TRUE(lock_scope.has_value());
1185 ASSERT_EQ(lock_scope->size(), 3U);
1186 EXPECT_EQ(lock_scope->at(0), 2459565876494606883U);
1187 EXPECT_EQ(lock_scope->at(1), 2459565876494606884U);
1188 EXPECT_EQ(lock_scope->at(2), 2459565876494606885U);
1189 safearray.Release();
1190}

◆ TEST() [81/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantMultipleUnknown   
)

Definition at line 1293 of file variant_vector_unittest.cc.

1293 {
1294 constexpr VARTYPE kVariantType = VT_UNKNOWN;
1295 VariantVector vector;
1296
1297 Microsoft::WRL::ComPtr<IUnknown> unknown1 =
1298 Microsoft::WRL::Make<DispatchStub>();
1299 Microsoft::WRL::ComPtr<IUnknown> unknown2 =
1300 Microsoft::WRL::Make<DispatchStub>();
1301
1302 vector.Insert<kVariantType>(unknown1.Get());
1303 vector.Insert<kVariantType>(unknown2.Get());
1304 EXPECT_EQ(vector.Type(), kVariantType);
1305 EXPECT_EQ(vector.Size(), 2U);
1306
1307 ScopedVariant variant(vector.ReleaseAsSafearrayVariant());
1308 EXPECT_EQ(vector.Type(), VT_EMPTY);
1309 EXPECT_EQ(vector.Size(), 0U);
1310 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
1311
1312 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
1313 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
1314 safearray.CreateLockScope<kVariantType>();
1315 ASSERT_TRUE(lock_scope.has_value());
1316 ASSERT_EQ(lock_scope->size(), 2U);
1317 EXPECT_EQ(lock_scope->at(0), unknown1.Get());
1318 EXPECT_EQ(lock_scope->at(1), unknown2.Get());
1319 safearray.Release();
1320}

◆ TEST() [82/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleBool   
)

Definition at line 616 of file variant_vector_unittest.cc.

616 {
617 constexpr VARTYPE kVariantType = VT_BOOL;
618 VariantVector vector;
619
620 vector.Insert<kVariantType>(true);
621 EXPECT_EQ(vector.Type(), kVariantType);
622 EXPECT_EQ(vector.Size(), 1U);
623
625 EXPECT_EQ(vector.Type(), VT_EMPTY);
626 EXPECT_EQ(vector.Size(), 0U);
627 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
628
629 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
630 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
631 safearray.CreateLockScope<kVariantType>();
632 ASSERT_TRUE(lock_scope.has_value());
633 ASSERT_EQ(lock_scope->size(), 1U);
634 EXPECT_EQ(lock_scope->at(0), VARIANT_TRUE);
635 safearray.Release();
636}

◆ TEST() [83/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleBstr   
)

Definition at line 885 of file variant_vector_unittest.cc.

885 {
886 constexpr VARTYPE kVariantType = VT_BSTR;
887 VariantVector vector;
888
889 wchar_t some_text[] = L"some text";
890 vector.Insert<kVariantType>(some_text);
891 EXPECT_EQ(vector.Type(), kVariantType);
892 EXPECT_EQ(vector.Size(), 1U);
893
895 EXPECT_EQ(vector.Type(), VT_EMPTY);
896 EXPECT_EQ(vector.Size(), 0U);
897 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
898
899 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
900 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
901 safearray.CreateLockScope<kVariantType>();
902 ASSERT_TRUE(lock_scope.has_value());
903 ASSERT_EQ(lock_scope->size(), 1U);
904 EXPECT_STREQ(lock_scope->at(0), some_text);
905 safearray.Release();
906}

◆ TEST() [84/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleDate   
)

Definition at line 858 of file variant_vector_unittest.cc.

858 {
859 constexpr VARTYPE kVariantType = VT_DATE;
860 VariantVector vector;
861
862 SYSTEMTIME sys_time;
863 ::GetSystemTime(&sys_time);
864 DATE date;
865 ::SystemTimeToVariantTime(&sys_time, &date);
866
867 vector.Insert<kVariantType>(date);
868 EXPECT_EQ(vector.Type(), kVariantType);
869 EXPECT_EQ(vector.Size(), 1U);
870
872 EXPECT_EQ(vector.Type(), VT_EMPTY);
873 EXPECT_EQ(vector.Size(), 0U);
874 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
875
876 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
877 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
878 safearray.CreateLockScope<kVariantType>();
879 ASSERT_TRUE(lock_scope.has_value());
880 ASSERT_EQ(lock_scope->size(), 1U);
881 EXPECT_EQ(lock_scope->at(0), date);
882 safearray.Release();
883}

◆ TEST() [85/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleDispatch   
)

Definition at line 933 of file variant_vector_unittest.cc.

933 {
934 constexpr VARTYPE kVariantType = VT_DISPATCH;
935 VariantVector vector;
936
937 Microsoft::WRL::ComPtr<IDispatch> dispatch =
938 Microsoft::WRL::Make<DispatchStub>();
939
940 vector.Insert<kVariantType>(dispatch.Get());
941 EXPECT_EQ(vector.Type(), kVariantType);
942 EXPECT_EQ(vector.Size(), 1U);
943
945 EXPECT_EQ(vector.Type(), VT_EMPTY);
946 EXPECT_EQ(vector.Size(), 0U);
947 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
948
949 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
950 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
951 safearray.CreateLockScope<kVariantType>();
952 ASSERT_TRUE(lock_scope.has_value());
953 ASSERT_EQ(lock_scope->size(), 1U);
954 EXPECT_EQ(lock_scope->at(0), dispatch.Get());
955 safearray.Release();
956}

◆ TEST() [86/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleI1   
)

Definition at line 638 of file variant_vector_unittest.cc.

638 {
639 constexpr VARTYPE kVariantType = VT_I1;
640 VariantVector vector;
641
642 vector.Insert<kVariantType>(34);
643 EXPECT_EQ(vector.Type(), kVariantType);
644 EXPECT_EQ(vector.Size(), 1U);
645
647 EXPECT_EQ(vector.Type(), VT_EMPTY);
648 EXPECT_EQ(vector.Size(), 0U);
649 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
650
651 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
652 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
653 safearray.CreateLockScope<kVariantType>();
654 ASSERT_TRUE(lock_scope.has_value());
655 ASSERT_EQ(lock_scope->size(), 1U);
656 EXPECT_EQ(lock_scope->at(0), 34);
657 safearray.Release();
658}

◆ TEST() [87/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleI2   
)

Definition at line 682 of file variant_vector_unittest.cc.

682 {
683 constexpr VARTYPE kVariantType = VT_I2;
684 VariantVector vector;
685
686 vector.Insert<kVariantType>(8738);
687 EXPECT_EQ(vector.Type(), kVariantType);
688 EXPECT_EQ(vector.Size(), 1U);
689
691 EXPECT_EQ(vector.Type(), VT_EMPTY);
692 EXPECT_EQ(vector.Size(), 0U);
693 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
694
695 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
696 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
697 safearray.CreateLockScope<kVariantType>();
698 ASSERT_TRUE(lock_scope.has_value());
699 ASSERT_EQ(lock_scope->size(), 1U);
700 EXPECT_EQ(lock_scope->at(0), 8738);
701 safearray.Release();
702}

◆ TEST() [88/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleI4   
)

Definition at line 726 of file variant_vector_unittest.cc.

726 {
727 constexpr VARTYPE kVariantType = VT_I4;
728 VariantVector vector;
729
730 vector.Insert<kVariantType>(572662306);
731 EXPECT_EQ(vector.Type(), kVariantType);
732 EXPECT_EQ(vector.Size(), 1U);
733
735 EXPECT_EQ(vector.Type(), VT_EMPTY);
736 EXPECT_EQ(vector.Size(), 0U);
737 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
738
739 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
740 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
741 safearray.CreateLockScope<kVariantType>();
742 ASSERT_TRUE(lock_scope.has_value());
743 ASSERT_EQ(lock_scope->size(), 1U);
744 EXPECT_EQ(lock_scope->at(0), 572662306);
745 safearray.Release();
746}

◆ TEST() [89/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleI8   
)

Definition at line 770 of file variant_vector_unittest.cc.

770 {
771 constexpr VARTYPE kVariantType = VT_I8;
772 VariantVector vector;
773
774 vector.Insert<kVariantType>(2459565876494606882);
775 EXPECT_EQ(vector.Type(), kVariantType);
776 EXPECT_EQ(vector.Size(), 1U);
777
779 EXPECT_EQ(vector.Type(), VT_EMPTY);
780 EXPECT_EQ(vector.Size(), 0U);
781 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
782
783 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
784 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
785 safearray.CreateLockScope<kVariantType>();
786 ASSERT_TRUE(lock_scope.has_value());
787 ASSERT_EQ(lock_scope->size(), 1U);
788 EXPECT_EQ(lock_scope->at(0), 2459565876494606882);
789 safearray.Release();
790}

◆ TEST() [90/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleR4   
)

Definition at line 814 of file variant_vector_unittest.cc.

814 {
815 constexpr VARTYPE kVariantType = VT_R4;
816 VariantVector vector;
817
818 vector.Insert<kVariantType>(3.14159f);
819 EXPECT_EQ(vector.Type(), kVariantType);
820 EXPECT_EQ(vector.Size(), 1U);
821
823 EXPECT_EQ(vector.Type(), VT_EMPTY);
824 EXPECT_EQ(vector.Size(), 0U);
825 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
826
827 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
828 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
829 safearray.CreateLockScope<kVariantType>();
830 ASSERT_TRUE(lock_scope.has_value());
831 ASSERT_EQ(lock_scope->size(), 1U);
832 EXPECT_EQ(lock_scope->at(0), 3.14159f);
833 safearray.Release();
834}

◆ TEST() [91/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleR8   
)

Definition at line 836 of file variant_vector_unittest.cc.

836 {
837 constexpr VARTYPE kVariantType = VT_R8;
838 VariantVector vector;
839
840 vector.Insert<kVariantType>(6.28318);
841 EXPECT_EQ(vector.Type(), kVariantType);
842 EXPECT_EQ(vector.Size(), 1U);
843
845 EXPECT_EQ(vector.Type(), VT_EMPTY);
846 EXPECT_EQ(vector.Size(), 0U);
847 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
848
849 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
850 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
851 safearray.CreateLockScope<kVariantType>();
852 ASSERT_TRUE(lock_scope.has_value());
853 ASSERT_EQ(lock_scope->size(), 1U);
854 EXPECT_EQ(lock_scope->at(0), 6.28318);
855 safearray.Release();
856}

◆ TEST() [92/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleUI1   
)

Definition at line 660 of file variant_vector_unittest.cc.

660 {
661 constexpr VARTYPE kVariantType = VT_UI1;
662 VariantVector vector;
663
664 vector.Insert<kVariantType>(34U);
665 EXPECT_EQ(vector.Type(), kVariantType);
666 EXPECT_EQ(vector.Size(), 1U);
667
669 EXPECT_EQ(vector.Type(), VT_EMPTY);
670 EXPECT_EQ(vector.Size(), 0U);
671 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
672
673 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
674 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
675 safearray.CreateLockScope<kVariantType>();
676 ASSERT_TRUE(lock_scope.has_value());
677 ASSERT_EQ(lock_scope->size(), 1U);
678 EXPECT_EQ(lock_scope->at(0), 34U);
679 safearray.Release();
680}

◆ TEST() [93/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleUI2   
)

Definition at line 704 of file variant_vector_unittest.cc.

704 {
705 constexpr VARTYPE kVariantType = VT_UI2;
706 VariantVector vector;
707
708 vector.Insert<kVariantType>(8739U);
709 EXPECT_EQ(vector.Type(), kVariantType);
710 EXPECT_EQ(vector.Size(), 1U);
711
713 EXPECT_EQ(vector.Type(), VT_EMPTY);
714 EXPECT_EQ(vector.Size(), 0U);
715 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
716
717 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
718 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
719 safearray.CreateLockScope<kVariantType>();
720 ASSERT_TRUE(lock_scope.has_value());
721 ASSERT_EQ(lock_scope->size(), 1U);
722 EXPECT_EQ(lock_scope->at(0), 8739U);
723 safearray.Release();
724}

◆ TEST() [94/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleUI4   
)

Definition at line 748 of file variant_vector_unittest.cc.

748 {
749 constexpr VARTYPE kVariantType = VT_UI4;
750 VariantVector vector;
751
752 vector.Insert<kVariantType>(578662306U);
753 EXPECT_EQ(vector.Type(), kVariantType);
754 EXPECT_EQ(vector.Size(), 1U);
755
757 EXPECT_EQ(vector.Type(), VT_EMPTY);
758 EXPECT_EQ(vector.Size(), 0U);
759 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
760
761 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
762 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
763 safearray.CreateLockScope<kVariantType>();
764 ASSERT_TRUE(lock_scope.has_value());
765 ASSERT_EQ(lock_scope->size(), 1U);
766 EXPECT_EQ(lock_scope->at(0), 578662306U);
767 safearray.Release();
768}

◆ TEST() [95/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleUI8   
)

Definition at line 792 of file variant_vector_unittest.cc.

792 {
793 constexpr VARTYPE kVariantType = VT_UI8;
794 VariantVector vector;
795
796 vector.Insert<kVariantType>(2459565876494606883U);
797 EXPECT_EQ(vector.Type(), kVariantType);
798 EXPECT_EQ(vector.Size(), 1U);
799
801 EXPECT_EQ(vector.Type(), VT_EMPTY);
802 EXPECT_EQ(vector.Size(), 0U);
803 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
804
805 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
806 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
807 safearray.CreateLockScope<kVariantType>();
808 ASSERT_TRUE(lock_scope.has_value());
809 ASSERT_EQ(lock_scope->size(), 1U);
810 EXPECT_EQ(lock_scope->at(0), 2459565876494606883U);
811 safearray.Release();
812}

◆ TEST() [96/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsSafearrayVariantSingleUnknown   
)

Definition at line 908 of file variant_vector_unittest.cc.

908 {
909 constexpr VARTYPE kVariantType = VT_UNKNOWN;
910 VariantVector vector;
911
912 Microsoft::WRL::ComPtr<IUnknown> unknown =
913 Microsoft::WRL::Make<DispatchStub>();
914
915 vector.Insert<kVariantType>(unknown.Get());
916 EXPECT_EQ(vector.Type(), kVariantType);
917 EXPECT_EQ(vector.Size(), 1U);
918
920 EXPECT_EQ(vector.Type(), VT_EMPTY);
921 EXPECT_EQ(vector.Size(), 0U);
922 EXPECT_EQ(variant.type(), VT_ARRAY | kVariantType);
923
924 ScopedSafearray safearray(V_ARRAY(variant.ptr()));
925 base::Optional<ScopedSafearray::LockScope<kVariantType>> lock_scope =
926 safearray.CreateLockScope<kVariantType>();
927 ASSERT_TRUE(lock_scope.has_value());
928 ASSERT_EQ(lock_scope->size(), 1U);
929 EXPECT_EQ(lock_scope->at(0), unknown.Get());
930 safearray.Release();
931}

◆ TEST() [97/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantEmpty   
)

Definition at line 173 of file variant_vector_unittest.cc.

173 {
174 VariantVector vector;
175 ScopedVariant variant(vector.ReleaseAsScalarVariant());
176 EXPECT_EQ(variant.type(), VT_EMPTY);
177}

◆ TEST() [98/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleBool   
)

Definition at line 413 of file variant_vector_unittest.cc.

413 {
414 constexpr VARTYPE kVariantType = VT_BOOL;
415 VariantVector vector;
416 ScopedVariant variant;
417
418 vector.Insert<kVariantType>(true);
419 vector.Insert<kVariantType>(false);
420 EXPECT_EQ(vector.Type(), kVariantType);
421 EXPECT_EQ(vector.Size(), 2U);
423}

◆ TEST() [99/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleBstr   
)

Definition at line 562 of file variant_vector_unittest.cc.

562 {
563 constexpr VARTYPE kVariantType = VT_BSTR;
564 VariantVector vector;
565 ScopedVariant variant;
566
567 wchar_t some_text[] = L"some text";
568 wchar_t more_text[] = L"more text";
569 vector.Insert<kVariantType>(some_text);
570 vector.Insert<kVariantType>(more_text);
571 EXPECT_EQ(vector.Type(), kVariantType);
572 EXPECT_EQ(vector.Size(), 2U);
574}

◆ TEST() [100/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleDate   
)

Definition at line 545 of file variant_vector_unittest.cc.

545 {
546 constexpr VARTYPE kVariantType = VT_DATE;
547 VariantVector vector;
548 ScopedVariant variant;
549
550 SYSTEMTIME sys_time;
551 ::GetSystemTime(&sys_time);
552 DATE date;
553 ::SystemTimeToVariantTime(&sys_time, &date);
554
555 vector.Insert<kVariantType>(date);
556 vector.Insert<kVariantType>(date);
557 EXPECT_EQ(vector.Type(), kVariantType);
558 EXPECT_EQ(vector.Size(), 2U);
560}

◆ TEST() [101/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleDispatch   
)

Definition at line 593 of file variant_vector_unittest.cc.

593 {
594 constexpr VARTYPE kVariantType = VT_DISPATCH;
595 VariantVector vector;
596 ScopedVariant variant;
597
598 Microsoft::WRL::ComPtr<IDispatch> dispatch1 =
599 Microsoft::WRL::Make<DispatchStub>();
600 Microsoft::WRL::ComPtr<IDispatch> dispatch2 =
601 Microsoft::WRL::Make<DispatchStub>();
602
603 vector.Insert<kVariantType>(dispatch1.Get());
604 vector.Insert<kVariantType>(dispatch2.Get());
605 EXPECT_EQ(vector.Type(), kVariantType);
606 EXPECT_EQ(vector.Size(), 2U);
608}

◆ TEST() [102/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleI1   
)

Definition at line 425 of file variant_vector_unittest.cc.

425 {
426 constexpr VARTYPE kVariantType = VT_I1;
427 VariantVector vector;
428 ScopedVariant variant;
429
430 vector.Insert<kVariantType>(34);
431 vector.Insert<kVariantType>(52);
432 EXPECT_EQ(vector.Type(), kVariantType);
433 EXPECT_EQ(vector.Size(), 2U);
435}

◆ TEST() [103/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleI2   
)

Definition at line 449 of file variant_vector_unittest.cc.

449 {
450 constexpr VARTYPE kVariantType = VT_I2;
451 VariantVector vector;
452 ScopedVariant variant;
453
454 vector.Insert<kVariantType>(8738);
455 vector.Insert<kVariantType>(8758);
456 EXPECT_EQ(vector.Type(), kVariantType);
457 EXPECT_EQ(vector.Size(), 2U);
459}

◆ TEST() [104/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleI4   
)

Definition at line 473 of file variant_vector_unittest.cc.

473 {
474 constexpr VARTYPE kVariantType = VT_I4;
475 VariantVector vector;
476 ScopedVariant variant;
477
478 vector.Insert<kVariantType>(572662306);
479 vector.Insert<kVariantType>(572662307);
480 EXPECT_EQ(vector.Type(), kVariantType);
481 EXPECT_EQ(vector.Size(), 2U);
483}

◆ TEST() [105/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleI8   
)

Definition at line 497 of file variant_vector_unittest.cc.

497 {
498 constexpr VARTYPE kVariantType = VT_I8;
499 VariantVector vector;
500 ScopedVariant variant;
501
502 vector.Insert<kVariantType>(2459565876494606882);
503 vector.Insert<kVariantType>(2459565876494606883);
504 EXPECT_EQ(vector.Type(), kVariantType);
505 EXPECT_EQ(vector.Size(), 2U);
507}

◆ TEST() [106/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleR4   
)

Definition at line 521 of file variant_vector_unittest.cc.

521 {
522 constexpr VARTYPE kVariantType = VT_R4;
523 VariantVector vector;
524 ScopedVariant variant;
525
526 vector.Insert<kVariantType>(3.14159f);
527 vector.Insert<kVariantType>(6.28318f);
528 EXPECT_EQ(vector.Type(), kVariantType);
529 EXPECT_EQ(vector.Size(), 2U);
531}

◆ TEST() [107/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleR8   
)

Definition at line 533 of file variant_vector_unittest.cc.

533 {
534 constexpr VARTYPE kVariantType = VT_R8;
535 VariantVector vector;
536 ScopedVariant variant;
537
538 vector.Insert<kVariantType>(6.28318);
539 vector.Insert<kVariantType>(3.14159);
540 EXPECT_EQ(vector.Type(), kVariantType);
541 EXPECT_EQ(vector.Size(), 2U);
543}

◆ TEST() [108/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleUI1   
)

Definition at line 437 of file variant_vector_unittest.cc.

437 {
438 constexpr VARTYPE kVariantType = VT_UI1;
439 VariantVector vector;
440 ScopedVariant variant;
441
442 vector.Insert<kVariantType>(34U);
443 vector.Insert<kVariantType>(52U);
444 EXPECT_EQ(vector.Type(), kVariantType);
445 EXPECT_EQ(vector.Size(), 2U);
447}

◆ TEST() [109/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleUI2   
)

Definition at line 461 of file variant_vector_unittest.cc.

461 {
462 constexpr VARTYPE kVariantType = VT_UI2;
463 VariantVector vector;
464 ScopedVariant variant;
465
466 vector.Insert<kVariantType>(8739U);
467 vector.Insert<kVariantType>(8759U);
468 EXPECT_EQ(vector.Type(), kVariantType);
469 EXPECT_EQ(vector.Size(), 2U);
471}

◆ TEST() [110/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleUI4   
)

Definition at line 485 of file variant_vector_unittest.cc.

485 {
486 constexpr VARTYPE kVariantType = VT_UI4;
487 VariantVector vector;
488 ScopedVariant variant;
489
490 vector.Insert<kVariantType>(578662306U);
491 vector.Insert<kVariantType>(578662307U);
492 EXPECT_EQ(vector.Type(), kVariantType);
493 EXPECT_EQ(vector.Size(), 2U);
495}

◆ TEST() [111/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleUI8   
)

Definition at line 509 of file variant_vector_unittest.cc.

509 {
510 constexpr VARTYPE kVariantType = VT_UI8;
511 VariantVector vector;
512 ScopedVariant variant;
513
514 vector.Insert<kVariantType>(2459565876494606883U);
515 vector.Insert<kVariantType>(2459565876494606884U);
516 EXPECT_EQ(vector.Type(), kVariantType);
517 EXPECT_EQ(vector.Size(), 2U);
519}

◆ TEST() [112/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantMultipleUnknown   
)

Definition at line 576 of file variant_vector_unittest.cc.

576 {
577 constexpr VARTYPE kVariantType = VT_UNKNOWN;
578 VariantVector vector;
579 ScopedVariant variant;
580
581 Microsoft::WRL::ComPtr<IUnknown> unknown1 =
582 Microsoft::WRL::Make<DispatchStub>();
583 Microsoft::WRL::ComPtr<IUnknown> unknown2 =
584 Microsoft::WRL::Make<DispatchStub>();
585
586 vector.Insert<kVariantType>(unknown1.Get());
587 vector.Insert<kVariantType>(unknown2.Get());
588 EXPECT_EQ(vector.Type(), kVariantType);
589 EXPECT_EQ(vector.Size(), 2U);
591}

◆ TEST() [113/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleBool   
)

Definition at line 179 of file variant_vector_unittest.cc.

179 {
180 VariantVector vector;
181 ScopedVariant expected_variant;
182
183 expected_variant.Set(true);
184 vector.Insert<VT_BOOL>(true);
185 EXPECT_EQ(vector.Type(), expected_variant.type());
186 EXPECT_EQ(vector.Size(), 1U);
187
188 ScopedVariant variant(vector.ReleaseAsScalarVariant());
189 EXPECT_EQ(vector.Type(), VT_EMPTY);
190 EXPECT_EQ(vector.Size(), 0U);
191 EXPECT_EQ(variant.Compare(expected_variant), 0);
192}

◆ TEST() [114/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleBstr   
)

Definition at line 363 of file variant_vector_unittest.cc.

363 {
364 VariantVector vector;
365 ScopedVariant expected_variant;
366
367 wchar_t test_string[] = L"Test string for BSTRs.";
368 expected_variant.Set(test_string);
369 vector.Insert<VT_BSTR>(test_string);
370 EXPECT_EQ(vector.Type(), expected_variant.type());
371 EXPECT_EQ(vector.Size(), 1U);
372
373 ScopedVariant variant(vector.ReleaseAsScalarVariant());
374 EXPECT_EQ(vector.Type(), VT_EMPTY);
375 EXPECT_EQ(vector.Size(), 0U);
376 EXPECT_EQ(variant.Compare(expected_variant), 0);
377}

◆ TEST() [115/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleDate   
)

Definition at line 344 of file variant_vector_unittest.cc.

344 {
345 VariantVector vector;
346 ScopedVariant expected_variant;
347
348 SYSTEMTIME sys_time;
349 ::GetSystemTime(&sys_time);
350 DATE date;
351 ::SystemTimeToVariantTime(&sys_time, &date);
352 expected_variant.SetDate(date);
353 vector.Insert<VT_DATE>(date);
354 EXPECT_EQ(vector.Type(), expected_variant.type());
355 EXPECT_EQ(vector.Size(), 1U);
356
357 ScopedVariant variant(vector.ReleaseAsScalarVariant());
358 EXPECT_EQ(vector.Type(), VT_EMPTY);
359 EXPECT_EQ(vector.Size(), 0U);
360 EXPECT_EQ(variant.Compare(expected_variant), 0);
361}

◆ TEST() [116/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleDispatch   
)

Definition at line 396 of file variant_vector_unittest.cc.

396 {
397 VariantVector vector;
398 ScopedVariant expected_variant;
399
400 Microsoft::WRL::ComPtr<IDispatch> dispatch =
401 Microsoft::WRL::Make<DispatchStub>();
402 expected_variant.Set(dispatch.Get());
403 vector.Insert<VT_DISPATCH>(dispatch.Get());
404 EXPECT_EQ(vector.Type(), expected_variant.type());
405 EXPECT_EQ(vector.Size(), 1U);
406
407 ScopedVariant variant(vector.ReleaseAsScalarVariant());
408 EXPECT_EQ(vector.Type(), VT_EMPTY);
409 EXPECT_EQ(vector.Size(), 0U);
410 EXPECT_EQ(variant.Compare(expected_variant), 0);
411}

◆ TEST() [117/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleI1   
)

Definition at line 194 of file variant_vector_unittest.cc.

194 {
195 VariantVector vector;
196 ScopedVariant expected_variant;
197
198 expected_variant.Set((int8_t)34);
199 vector.Insert<VT_I1>(34);
200 EXPECT_EQ(vector.Type(), expected_variant.type());
201 EXPECT_EQ(vector.Size(), 1U);
202
203 ScopedVariant variant(vector.ReleaseAsScalarVariant());
204 EXPECT_EQ(vector.Type(), VT_EMPTY);
205 EXPECT_EQ(vector.Size(), 0U);
206 EXPECT_EQ(variant.Compare(expected_variant), 0);
207}

◆ TEST() [118/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleI2   
)

Definition at line 224 of file variant_vector_unittest.cc.

224 {
225 VariantVector vector;
226 ScopedVariant expected_variant;
227
228 expected_variant.Set((int16_t)8738);
229 vector.Insert<VT_I2>(8738);
230 EXPECT_EQ(vector.Type(), expected_variant.type());
231 EXPECT_EQ(vector.Size(), 1U);
232
233 ScopedVariant variant(vector.ReleaseAsScalarVariant());
234 EXPECT_EQ(vector.Type(), VT_EMPTY);
235 EXPECT_EQ(vector.Size(), 0U);
236 EXPECT_EQ(variant.Compare(expected_variant), 0);
237}

◆ TEST() [119/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleI4   
)

Definition at line 254 of file variant_vector_unittest.cc.

254 {
255 VariantVector vector;
256 ScopedVariant expected_variant;
257
258 expected_variant.Set((int32_t)572662306);
259 vector.Insert<VT_I4>(572662306);
260 EXPECT_EQ(vector.Type(), expected_variant.type());
261 EXPECT_EQ(vector.Size(), 1U);
262
263 ScopedVariant variant(vector.ReleaseAsScalarVariant());
264 EXPECT_EQ(vector.Type(), VT_EMPTY);
265 EXPECT_EQ(vector.Size(), 0U);
266 EXPECT_EQ(variant.Compare(expected_variant), 0);
267}

◆ TEST() [120/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleI8   
)

Definition at line 284 of file variant_vector_unittest.cc.

284 {
285 VariantVector vector;
286 ScopedVariant expected_variant;
287
288 expected_variant.Set((int64_t)2459565876494606882);
289 vector.Insert<VT_I8>(2459565876494606882);
290 EXPECT_EQ(vector.Type(), expected_variant.type());
291 EXPECT_EQ(vector.Size(), 1U);
292
293 ScopedVariant variant(vector.ReleaseAsScalarVariant());
294 EXPECT_EQ(vector.Type(), VT_EMPTY);
295 EXPECT_EQ(vector.Size(), 0U);
296 EXPECT_EQ(variant.Compare(expected_variant), 0);
297}

◆ TEST() [121/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleR4   
)

Definition at line 314 of file variant_vector_unittest.cc.

314 {
315 VariantVector vector;
316 ScopedVariant expected_variant;
317
318 expected_variant.Set(3.14159f);
319 vector.Insert<VT_R4>(3.14159f);
320 EXPECT_EQ(vector.Type(), expected_variant.type());
321 EXPECT_EQ(vector.Size(), 1U);
322
323 ScopedVariant variant(vector.ReleaseAsScalarVariant());
324 EXPECT_EQ(vector.Type(), VT_EMPTY);
325 EXPECT_EQ(vector.Size(), 0U);
326 EXPECT_EQ(variant.Compare(expected_variant), 0);
327}

◆ TEST() [122/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleR8   
)

Definition at line 329 of file variant_vector_unittest.cc.

329 {
330 VariantVector vector;
331 ScopedVariant expected_variant;
332
333 expected_variant.Set(6.28318);
334 vector.Insert<VT_R8>(6.28318);
335 EXPECT_EQ(vector.Type(), expected_variant.type());
336 EXPECT_EQ(vector.Size(), 1U);
337
338 ScopedVariant variant(vector.ReleaseAsScalarVariant());
339 EXPECT_EQ(vector.Type(), VT_EMPTY);
340 EXPECT_EQ(vector.Size(), 0U);
341 EXPECT_EQ(variant.Compare(expected_variant), 0);
342}

◆ TEST() [123/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleUI1   
)

Definition at line 209 of file variant_vector_unittest.cc.

209 {
210 VariantVector vector;
211 ScopedVariant expected_variant;
212
213 expected_variant.Set((uint8_t)35U);
214 vector.Insert<VT_UI1>(35U);
215 EXPECT_EQ(vector.Type(), expected_variant.type());
216 EXPECT_EQ(vector.Size(), 1U);
217
218 ScopedVariant variant(vector.ReleaseAsScalarVariant());
219 EXPECT_EQ(vector.Type(), VT_EMPTY);
220 EXPECT_EQ(vector.Size(), 0U);
221 EXPECT_EQ(variant.Compare(expected_variant), 0);
222}

◆ TEST() [124/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleUI2   
)

Definition at line 239 of file variant_vector_unittest.cc.

239 {
240 VariantVector vector;
241 ScopedVariant expected_variant;
242
243 expected_variant.Set((uint16_t)8739U);
244 vector.Insert<VT_UI2>(8739U);
245 EXPECT_EQ(vector.Type(), expected_variant.type());
246 EXPECT_EQ(vector.Size(), 1U);
247
248 ScopedVariant variant(vector.ReleaseAsScalarVariant());
249 EXPECT_EQ(vector.Type(), VT_EMPTY);
250 EXPECT_EQ(vector.Size(), 0U);
251 EXPECT_EQ(variant.Compare(expected_variant), 0);
252}

◆ TEST() [125/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleUI4   
)

Definition at line 269 of file variant_vector_unittest.cc.

269 {
270 VariantVector vector;
271 ScopedVariant expected_variant;
272
273 expected_variant.Set((uint32_t)572662307U);
274 vector.Insert<VT_UI4>(572662307U);
275 EXPECT_EQ(vector.Type(), expected_variant.type());
276 EXPECT_EQ(vector.Size(), 1U);
277
278 ScopedVariant variant(vector.ReleaseAsScalarVariant());
279 EXPECT_EQ(vector.Type(), VT_EMPTY);
280 EXPECT_EQ(vector.Size(), 0U);
281 EXPECT_EQ(variant.Compare(expected_variant), 0);
282}

◆ TEST() [126/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleUI8   
)

Definition at line 299 of file variant_vector_unittest.cc.

299 {
300 VariantVector vector;
301 ScopedVariant expected_variant;
302
303 expected_variant.Set((uint64_t)2459565876494606883U);
304 vector.Insert<VT_UI8>(2459565876494606883U);
305 EXPECT_EQ(vector.Type(), expected_variant.type());
306 EXPECT_EQ(vector.Size(), 1U);
307
308 ScopedVariant variant(vector.ReleaseAsScalarVariant());
309 EXPECT_EQ(vector.Type(), VT_EMPTY);
310 EXPECT_EQ(vector.Size(), 0U);
311 EXPECT_EQ(variant.Compare(expected_variant), 0);
312}

◆ TEST() [127/130]

base::win::TEST ( VariantVectorTest  ,
ReleaseAsScalarVariantSingleUnknown   
)

Definition at line 379 of file variant_vector_unittest.cc.

379 {
380 VariantVector vector;
381 ScopedVariant expected_variant;
382
383 Microsoft::WRL::ComPtr<IUnknown> unknown =
384 Microsoft::WRL::Make<DispatchStub>();
385 expected_variant.Set(unknown.Get());
386 vector.Insert<VT_UNKNOWN>(unknown.Get());
387 EXPECT_EQ(vector.Type(), expected_variant.type());
388 EXPECT_EQ(vector.Size(), 1U);
389
390 ScopedVariant variant(vector.ReleaseAsScalarVariant());
391 EXPECT_EQ(vector.Type(), VT_EMPTY);
392 EXPECT_EQ(vector.Size(), 0U);
393 EXPECT_EQ(variant.Compare(expected_variant), 0);
394}

◆ TEST() [128/130]

base::win::TEST ( VariantVectorTest  ,
Reset   
)

Definition at line 119 of file variant_vector_unittest.cc.

119 {
120 VariantVector vector;
121 EXPECT_EQ(vector.Type(), VT_EMPTY);
122 EXPECT_EQ(vector.Size(), 0U);
123 vector.Insert<VT_I4>(123);
124 vector.Insert<VT_I4>(456);
125 EXPECT_EQ(vector.Type(), VT_I4);
126 EXPECT_EQ(vector.Size(), 2U);
127 vector.Reset();
128 EXPECT_EQ(vector.Type(), VT_EMPTY);
129 EXPECT_EQ(vector.Size(), 0U);
130}

◆ TEST() [129/130]

base::win::TEST ( VariantVectorTest  ,
ResetWithManagedContents   
)

Definition at line 132 of file variant_vector_unittest.cc.

132 {
133 VariantVector vector;
134 // Test that managed contents are released when cleared.
135 Microsoft::WRL::ComPtr<IUnknown> unknown1 =
136 Microsoft::WRL::Make<DispatchStub>();
137 Microsoft::WRL::ComPtr<IUnknown> unknown2;
138 unknown1.CopyTo(&unknown2);
139 vector.Insert<VT_UNKNOWN>(unknown1.Get());
140 EXPECT_EQ(vector.Type(), VT_UNKNOWN);
141 EXPECT_EQ(vector.Size(), 1U);
142 // There are now 3 references to the value owned by |unknown1|.
143 // Remove ownership from |unknown2| should reduce the count to 2.
144 EXPECT_EQ(unknown2.Reset(), 2U);
145 // Resetting the VariantVector will reduce the count to 1.
146 vector.Reset();
147 EXPECT_EQ(vector.Type(), VT_EMPTY);
148 EXPECT_EQ(vector.Size(), 0U);
149 // Then resetting |unknown1| should reduce to 0.
150 EXPECT_EQ(unknown1.Reset(), 0U);
151}

◆ TEST() [130/130]

base::win::TEST ( VariantVectorTest  ,
ScopeWithManagedContents   
)

Definition at line 153 of file variant_vector_unittest.cc.

153 {
154 Microsoft::WRL::ComPtr<IUnknown> unknown1 =
155 Microsoft::WRL::Make<DispatchStub>();
156 {
157 VariantVector vector;
158 vector.Insert<VT_UNKNOWN>(unknown1.Get());
159 EXPECT_EQ(vector.Type(), VT_UNKNOWN);
160 EXPECT_EQ(vector.Size(), 1U);
161
162 Microsoft::WRL::ComPtr<IUnknown> unknown2;
163 unknown1.CopyTo(&unknown2);
164 // There are now 3 references to the value owned by |unknown1|.
165 // Remove ownership from |unknown2| should reduce the count to 2.
166 EXPECT_EQ(unknown2.Reset(), 2U);
167 }
168 // The VariantVector going out of scope will reduce the count to 1.
169 // Then resetting |unknown1| should reduce to 0.
170 EXPECT_EQ(unknown1.Reset(), 0U);
171}