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

Side by Side Diff: base/scoped_comptr_win_unittest.cc

Issue 40256: Pulling in operator=() to ScopedComPtr. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « base/scoped_comptr_win.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <shlobj.h> 5 #include <shlobj.h>
6 6
7 #include "base/scoped_comptr_win.h" 7 #include "base/scoped_comptr_win.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 TEST(ScopedComPtrTest, ScopedComPtr) { 10 TEST(ScopedComPtrTest, ScopedComPtr) {
(...skipping 11 matching lines...) Expand all
22 EXPECT_TRUE(unk2 != NULL); 22 EXPECT_TRUE(unk2 != NULL);
23 23
24 ScopedComPtr<IMalloc> mem_alloc; 24 ScopedComPtr<IMalloc> mem_alloc;
25 EXPECT_TRUE(SUCCEEDED(CoGetMalloc(1, mem_alloc.Receive()))); 25 EXPECT_TRUE(SUCCEEDED(CoGetMalloc(1, mem_alloc.Receive())));
26 26
27 // test ScopedComPtr& constructor 27 // test ScopedComPtr& constructor
28 ScopedComPtr<IMalloc> copy1(mem_alloc); 28 ScopedComPtr<IMalloc> copy1(mem_alloc);
29 EXPECT_TRUE(copy1.IsSameObject(mem_alloc)); 29 EXPECT_TRUE(copy1.IsSameObject(mem_alloc));
30 EXPECT_FALSE(copy1.IsSameObject(unk2)); // unk2 is valid but different 30 EXPECT_FALSE(copy1.IsSameObject(unk2)); // unk2 is valid but different
31 EXPECT_FALSE(copy1.IsSameObject(unk)); // unk is NULL 31 EXPECT_FALSE(copy1.IsSameObject(unk)); // unk is NULL
32
33 IMalloc* naked_copy = copy1.Detach();
34 copy1 = naked_copy; // Test the =(T*) operator.
35 naked_copy->Release();
36
32 copy1.Release(); 37 copy1.Release();
33 EXPECT_FALSE(copy1.IsSameObject(unk2)); // unk2 is valid, copy1 is not 38 EXPECT_FALSE(copy1.IsSameObject(unk2)); // unk2 is valid, copy1 is not
34 39
35 // test Interface* constructor 40 // test Interface* constructor
36 ScopedComPtr<IMalloc> copy2(static_cast<IMalloc*>(mem_alloc)); 41 ScopedComPtr<IMalloc> copy2(static_cast<IMalloc*>(mem_alloc));
37 EXPECT_TRUE(copy2.IsSameObject(mem_alloc)); 42 EXPECT_TRUE(copy2.IsSameObject(mem_alloc));
38 43
39 EXPECT_TRUE(SUCCEEDED(unk.QueryFrom(mem_alloc))); 44 EXPECT_TRUE(SUCCEEDED(unk.QueryFrom(mem_alloc)));
40 EXPECT_TRUE(unk != NULL); 45 EXPECT_TRUE(unk != NULL);
41 unk.Release(); 46 unk.Release();
42 EXPECT_TRUE(unk == NULL); 47 EXPECT_TRUE(unk == NULL);
43 EXPECT_TRUE(unk.IsSameObject(copy1)); // both are NULL 48 EXPECT_TRUE(unk.IsSameObject(copy1)); // both are NULL
44 } 49 }
45 50
46 ::CoUninitialize(); 51 ::CoUninitialize();
47 } 52 }
OLDNEW
« no previous file with comments | « base/scoped_comptr_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698