summaryrefslogtreecommitdiffstats
path: root/base/scoped_comptr_win_unittest.cc
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-15 17:16:48 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-15 17:16:48 +0000
commitf5f36152e843a215629f3991da644f8da37e02ff (patch)
treec9dafdaaef442446e6d2d74f3a4e68fd104b6f47 /base/scoped_comptr_win_unittest.cc
parent4e486eb3962f64f3f9d4b9ae71d030edd4c01a5b (diff)
downloadchromium_src-f5f36152e843a215629f3991da644f8da37e02ff.zip
chromium_src-f5f36152e843a215629f3991da644f8da37e02ff.tar.gz
chromium_src-f5f36152e843a215629f3991da644f8da37e02ff.tar.bz2
Renaming the following files to include the _win suffix:
scoped_comptr*.* scoped_bstr*.* addition: time_unittest_win.cc -> time_win_unittest.cc BUG=6409 Also renaming the scoped_comptr class to ScopedComPtr to conform with chromium style (and not boost as before). Review URL: http://codereview.chromium.org/18054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/scoped_comptr_win_unittest.cc')
-rw-r--r--base/scoped_comptr_win_unittest.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/base/scoped_comptr_win_unittest.cc b/base/scoped_comptr_win_unittest.cc
new file mode 100644
index 0000000..96ebcc6
--- /dev/null
+++ b/base/scoped_comptr_win_unittest.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <shlobj.h>
+
+#include "base/scoped_comptr_win.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+TEST(ScopedComPtrTest, ScopedComPtr) {
+ EXPECT_TRUE(memcmp(&ScopedComPtr<IUnknown>::iid(), &IID_IUnknown,
+ sizeof(IID)) == 0);
+
+ EXPECT_TRUE(SUCCEEDED(::CoInitialize(NULL)));
+
+ {
+ ScopedComPtr<IUnknown> unk;
+ EXPECT_TRUE(SUCCEEDED(unk.CreateInstance(CLSID_ShellLink)));
+ ScopedComPtr<IUnknown> unk2;
+ unk2.Attach(unk.Detach());
+ EXPECT_TRUE(unk == NULL);
+ EXPECT_TRUE(unk2 != NULL);
+
+ ScopedComPtr<IMalloc> mem_alloc;
+ EXPECT_TRUE(SUCCEEDED(CoGetMalloc(1, mem_alloc.Receive())));
+
+ // 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
+ copy1.Release();
+ EXPECT_FALSE(copy1.IsSameObject(unk2)); // unk2 is valid, copy1 is not
+
+ // test Interface* constructor
+ ScopedComPtr<IMalloc> copy2(static_cast<IMalloc*>(mem_alloc));
+ EXPECT_TRUE(copy2.IsSameObject(mem_alloc));
+
+ EXPECT_TRUE(SUCCEEDED(unk.QueryFrom(mem_alloc)));
+ EXPECT_TRUE(unk != NULL);
+ unk.Release();
+ EXPECT_TRUE(unk == NULL);
+ EXPECT_TRUE(unk.IsSameObject(copy1)); // both are NULL
+ }
+
+ ::CoUninitialize();
+}