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

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

Issue 2789273002: Add IID_PPV_ARGS_Helper for ScopedComPtr (Closed)
Patch Set: Created 3 years, 8 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_comptr.h ('k') | no next file » | 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_comptr.h" 5 #include "base/win/scoped_comptr.h"
6 6
7 #include <objbase.h>
7 #include <shlobj.h> 8 #include <shlobj.h>
8 9
9 #include <memory> 10 #include <memory>
10 11
11 #include "base/win/scoped_com_initializer.h" 12 #include "base/win/scoped_com_initializer.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace base { 15 namespace base {
15 namespace win { 16 namespace win {
16 17
(...skipping 27 matching lines...) Expand all
44 EXPECT_TRUE(SUCCEEDED(unk.CreateInstance(CLSID_ShellLink))); 45 EXPECT_TRUE(SUCCEEDED(unk.CreateInstance(CLSID_ShellLink)));
45 ScopedComPtr<IUnknown> unk2; 46 ScopedComPtr<IUnknown> unk2;
46 unk2.Attach(unk.Detach()); 47 unk2.Attach(unk.Detach());
47 EXPECT_TRUE(unk.get() == NULL); 48 EXPECT_TRUE(unk.get() == NULL);
48 EXPECT_TRUE(unk2.get() != NULL); 49 EXPECT_TRUE(unk2.get() != NULL);
49 50
50 ScopedComPtr<IMalloc> mem_alloc; 51 ScopedComPtr<IMalloc> mem_alloc;
51 EXPECT_TRUE(SUCCEEDED(CoGetMalloc(1, mem_alloc.Receive()))); 52 EXPECT_TRUE(SUCCEEDED(CoGetMalloc(1, mem_alloc.Receive())));
52 53
53 ScopedComPtr<IUnknown> qi_test; 54 ScopedComPtr<IUnknown> qi_test;
54 EXPECT_HRESULT_SUCCEEDED(mem_alloc.QueryInterface(IID_IUnknown, 55 EXPECT_HRESULT_SUCCEEDED(mem_alloc.QueryInterface(IID_PPV_ARGS(&qi_test)));
55 reinterpret_cast<void**>(qi_test.Receive())));
56 EXPECT_TRUE(qi_test.get() != NULL); 56 EXPECT_TRUE(qi_test.get() != NULL);
57 qi_test.Release(); 57 qi_test.Release();
58 58
59 // test ScopedComPtr& constructor 59 // test ScopedComPtr& constructor
60 ScopedComPtr<IMalloc> copy1(mem_alloc); 60 ScopedComPtr<IMalloc> copy1(mem_alloc);
61 EXPECT_TRUE(copy1.IsSameObject(mem_alloc.get())); 61 EXPECT_TRUE(copy1.IsSameObject(mem_alloc.get()));
62 EXPECT_FALSE(copy1.IsSameObject(unk2.get())); // unk2 is valid but different 62 EXPECT_FALSE(copy1.IsSameObject(unk2.get())); // unk2 is valid but different
63 EXPECT_FALSE(copy1.IsSameObject(unk.get())); // unk is NULL 63 EXPECT_FALSE(copy1.IsSameObject(unk.get())); // unk is NULL
64 64
65 IMalloc* naked_copy = copy1.Detach(); 65 IMalloc* naked_copy = copy1.Detach();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 bleh.pop_back(); 105 bleh.pop_back();
106 EXPECT_EQ(p->adds, 4); 106 EXPECT_EQ(p->adds, 4);
107 EXPECT_EQ(p->releases, 2); 107 EXPECT_EQ(p->releases, 2);
108 } 108 }
109 EXPECT_EQ(p->adds, 4); 109 EXPECT_EQ(p->adds, 4);
110 EXPECT_EQ(p->releases, 4); 110 EXPECT_EQ(p->releases, 4);
111 } 111 }
112 112
113 } // namespace win 113 } // namespace win
114 } // namespace base 114 } // namespace base
OLDNEW
« no previous file with comments | « base/win/scoped_comptr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698