OLD | NEW |
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 <objbase.h> |
8 #include <shlobj.h> | 8 #include <shlobj.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 21 matching lines...) Expand all Loading... |
32 0x5678u, | 32 0x5678u, |
33 {01, 23, 45, 67, 89, 01, 23, 45}}; | 33 {01, 23, 45, 67, 89, 01, 23, 45}}; |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 TEST(ScopedComPtrTest, ScopedComPtr) { | 37 TEST(ScopedComPtrTest, ScopedComPtr) { |
38 base::win::ScopedCOMInitializer com_initializer; | 38 base::win::ScopedCOMInitializer com_initializer; |
39 EXPECT_TRUE(com_initializer.succeeded()); | 39 EXPECT_TRUE(com_initializer.succeeded()); |
40 | 40 |
41 ScopedComPtr<IUnknown> unk; | 41 ScopedComPtr<IUnknown> unk; |
42 EXPECT_TRUE(SUCCEEDED(unk.CreateInstance(CLSID_ShellLink))); | 42 EXPECT_TRUE(SUCCEEDED(::CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_ALL, |
| 43 IID_PPV_ARGS(&unk)))); |
43 ScopedComPtr<IUnknown> unk2; | 44 ScopedComPtr<IUnknown> unk2; |
44 unk2.Attach(unk.Detach()); | 45 unk2.Attach(unk.Detach()); |
45 EXPECT_TRUE(unk.Get() == NULL); | 46 EXPECT_TRUE(unk.Get() == NULL); |
46 EXPECT_TRUE(unk2.Get() != NULL); | 47 EXPECT_TRUE(unk2.Get() != NULL); |
47 | 48 |
48 ScopedComPtr<IMalloc> mem_alloc; | 49 ScopedComPtr<IMalloc> mem_alloc; |
49 EXPECT_TRUE(SUCCEEDED(CoGetMalloc(1, mem_alloc.GetAddressOf()))); | 50 EXPECT_TRUE(SUCCEEDED(CoGetMalloc(1, mem_alloc.GetAddressOf()))); |
50 | 51 |
51 ScopedComPtr<IUnknown> qi_test; | 52 ScopedComPtr<IUnknown> qi_test; |
52 EXPECT_HRESULT_SUCCEEDED(mem_alloc.CopyTo(IID_PPV_ARGS(&qi_test))); | 53 EXPECT_HRESULT_SUCCEEDED(mem_alloc.CopyTo(IID_PPV_ARGS(&qi_test))); |
(...skipping 25 matching lines...) Expand all Loading... |
78 bleh.pop_back(); | 79 bleh.pop_back(); |
79 EXPECT_EQ(p->adds, 4); | 80 EXPECT_EQ(p->adds, 4); |
80 EXPECT_EQ(p->releases, 2); | 81 EXPECT_EQ(p->releases, 2); |
81 } | 82 } |
82 EXPECT_EQ(p->adds, 4); | 83 EXPECT_EQ(p->adds, 4); |
83 EXPECT_EQ(p->releases, 4); | 84 EXPECT_EQ(p->releases, 4); |
84 } | 85 } |
85 | 86 |
86 } // namespace win | 87 } // namespace win |
87 } // namespace base | 88 } // namespace base |
OLD | NEW |