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

Side by Side Diff: base/win/scoped_variant_unittest.cc

Issue 1128733002: Update from https://crrev.com/328418 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/win/scoped_hdc.h ('k') | base/win/shortcut.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/win/scoped_variant.h" 5 #include "base/win/scoped_variant.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 namespace base { 8 namespace base {
9 namespace win { 9 namespace win {
10 10
11 namespace { 11 namespace {
12 12
13 static const wchar_t kTestString1[] = L"Used to create BSTRs"; 13 static const wchar_t kTestString1[] = L"Used to create BSTRs";
14 static const wchar_t kTestString2[] = L"Also used to create BSTRs"; 14 static const wchar_t kTestString2[] = L"Also used to create BSTRs";
15 15
16 void GiveMeAVariant(VARIANT* ret) { 16 void GiveMeAVariant(VARIANT* ret) {
17 EXPECT_TRUE(ret != NULL); 17 EXPECT_TRUE(ret != NULL);
18 ret->vt = VT_BSTR; 18 ret->vt = VT_BSTR;
19 V_BSTR(ret) = ::SysAllocString(kTestString1); 19 V_BSTR(ret) = ::SysAllocString(kTestString1);
20 } 20 }
21 21
22 // A dummy IDispatch implementation (if you can call it that). 22 // A dummy IDispatch implementation (if you can call it that).
23 // The class does nothing intelligent really. Only increments a counter 23 // The class does nothing intelligent really. Only increments a counter
24 // when AddRef is called and decrements it when Release is called. 24 // when AddRef is called and decrements it when Release is called.
25 class FakeComObject : public IDispatch { 25 class FakeComObject : public IDispatch {
26 public: 26 public:
27 FakeComObject() : ref_(0) { 27 FakeComObject() : ref_(0) {
28 } 28 }
29 29
30 STDMETHOD_(DWORD, AddRef)() { 30 STDMETHOD_(DWORD, AddRef)() override {
31 ref_++; 31 ref_++;
32 return ref_; 32 return ref_;
33 } 33 }
34 34
35 STDMETHOD_(DWORD, Release)() { 35 STDMETHOD_(DWORD, Release)() override {
36 ref_--; 36 ref_--;
37 return ref_; 37 return ref_;
38 } 38 }
39 39
40 STDMETHOD(QueryInterface)(REFIID, void**) { 40 STDMETHOD(QueryInterface)(REFIID, void**) override { return E_NOTIMPL; }
41
42 STDMETHOD(GetTypeInfoCount)(UINT*) override { return E_NOTIMPL; }
43
44 STDMETHOD(GetTypeInfo)(UINT, LCID, ITypeInfo**) override { return E_NOTIMPL; }
45
46 STDMETHOD(GetIDsOfNames)(REFIID, LPOLESTR*, UINT, LCID, DISPID*) override {
41 return E_NOTIMPL; 47 return E_NOTIMPL;
42 } 48 }
43 49
44 STDMETHOD(GetTypeInfoCount)(UINT*) { 50 STDMETHOD(Invoke)(DISPID,
51 REFIID,
52 LCID,
53 WORD,
54 DISPPARAMS*,
55 VARIANT*,
56 EXCEPINFO*,
57 UINT*) override {
45 return E_NOTIMPL; 58 return E_NOTIMPL;
46 } 59 }
47 60
48 STDMETHOD(GetTypeInfo)(UINT, LCID, ITypeInfo**) {
49 return E_NOTIMPL;
50 }
51
52 STDMETHOD(GetIDsOfNames)(REFIID, LPOLESTR*, UINT, LCID, DISPID*) {
53 return E_NOTIMPL;
54 }
55
56 STDMETHOD(Invoke)(DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*,
57 EXCEPINFO*, UINT*) {
58 return E_NOTIMPL;
59 }
60
61 // A way to check the internal reference count of the class. 61 // A way to check the internal reference count of the class.
62 int ref_count() const { 62 int ref_count() const {
63 return ref_; 63 return ref_;
64 } 64 }
65 65
66 protected: 66 protected:
67 int ref_; 67 int ref_;
68 }; 68 };
69 69
70 } // namespace 70 } // namespace
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 252
253 var.Set(sa); 253 var.Set(sa);
254 EXPECT_TRUE(ScopedVariant::IsLeakableVarType(var.type())); 254 EXPECT_TRUE(ScopedVariant::IsLeakableVarType(var.type()));
255 EXPECT_EQ(VT_ARRAY | VT_UI1, var.type()); 255 EXPECT_EQ(VT_ARRAY | VT_UI1, var.type());
256 EXPECT_EQ(sa, V_ARRAY(var.ptr())); 256 EXPECT_EQ(sa, V_ARRAY(var.ptr()));
257 // The array is destroyed in the destructor of var. 257 // The array is destroyed in the destructor of var.
258 } 258 }
259 259
260 } // namespace win 260 } // namespace win
261 } // namespace base 261 } // namespace base
OLDNEW
« no previous file with comments | « base/win/scoped_hdc.h ('k') | base/win/shortcut.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698