Skip to content

Commit

Permalink
Remove implicit conversions from scoped_refptr to T* in base/win/
Browse files Browse the repository at this point in the history
This patch was generated by running the rewrite_scoped_refptr clang tool
on a Windows build.

BUG=110610

Review URL: https://codereview.chromium.org/719363002

Cr-Commit-Position: refs/heads/master@{#304106}
  • Loading branch information
zetafunction authored and Commit bot committed Nov 13, 2014
1 parent be20825 commit 4a6041e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions base/win/scoped_comptr_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ TEST(ScopedComPtrTest, ScopedComPtr) {
EXPECT_TRUE(SUCCEEDED(unk.CreateInstance(CLSID_ShellLink)));
ScopedComPtr<IUnknown> unk2;
unk2.Attach(unk.Detach());
EXPECT_TRUE(unk == NULL);
EXPECT_TRUE(unk2 != NULL);
EXPECT_TRUE(unk.get() == NULL);
EXPECT_TRUE(unk2.get() != NULL);

ScopedComPtr<IMalloc> mem_alloc;
EXPECT_TRUE(SUCCEEDED(CoGetMalloc(1, mem_alloc.Receive())));
Expand All @@ -55,26 +55,26 @@ TEST(ScopedComPtrTest, ScopedComPtr) {

// test ScopedComPtr& constructor
ScopedComPtr<IMalloc> copy1(mem_alloc);
EXPECT_TRUE(copy1.IsSameObject(mem_alloc));
EXPECT_FALSE(copy1.IsSameObject(unk2)); // unk2 is valid but different
EXPECT_FALSE(copy1.IsSameObject(unk)); // unk is NULL
EXPECT_TRUE(copy1.IsSameObject(mem_alloc.get()));
EXPECT_FALSE(copy1.IsSameObject(unk2.get())); // unk2 is valid but different
EXPECT_FALSE(copy1.IsSameObject(unk.get())); // unk is NULL

IMalloc* naked_copy = copy1.Detach();
copy1 = naked_copy; // Test the =(T*) operator.
naked_copy->Release();

copy1.Release();
EXPECT_FALSE(copy1.IsSameObject(unk2)); // unk2 is valid, copy1 is not
EXPECT_FALSE(copy1.IsSameObject(unk2.get())); // unk2 is valid, copy1 is not

// test Interface* constructor
ScopedComPtr<IMalloc> copy2(static_cast<IMalloc*>(mem_alloc));
EXPECT_TRUE(copy2.IsSameObject(mem_alloc));
ScopedComPtr<IMalloc> copy2(static_cast<IMalloc*>(mem_alloc.get()));
EXPECT_TRUE(copy2.IsSameObject(mem_alloc.get()));

EXPECT_TRUE(SUCCEEDED(unk.QueryFrom(mem_alloc)));
EXPECT_TRUE(unk != NULL);
EXPECT_TRUE(SUCCEEDED(unk.QueryFrom(mem_alloc.get())));
EXPECT_TRUE(unk.get() != NULL);
unk.Release();
EXPECT_TRUE(unk == NULL);
EXPECT_TRUE(unk.IsSameObject(copy1)); // both are NULL
EXPECT_TRUE(unk.get() == NULL);
EXPECT_TRUE(unk.IsSameObject(copy1.get())); // both are NULL
}

TEST(ScopedComPtrTest, ScopedComPtrVector) {
Expand All @@ -98,7 +98,7 @@ TEST(ScopedComPtrTest, ScopedComPtrVector) {
bleh.push_back(p2);
EXPECT_EQ(p->adds, 4);
EXPECT_EQ(p->releases, 1);
EXPECT_EQ(bleh[0], p.get());
EXPECT_EQ(bleh[0].get(), p.get());
bleh.pop_back();
EXPECT_EQ(p->adds, 4);
EXPECT_EQ(p->releases, 2);
Expand Down

0 comments on commit 4a6041e

Please sign in to comment.