OLD | NEW |
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 <windows.h> | 5 #include <windows.h> |
6 | 6 |
7 #include "chrome/installer/util/wmi.h" | 7 #include "chrome/installer/util/wmi.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace installer { | 10 namespace installer { |
11 | 11 |
12 TEST(WMITest, TestLocalConnectionSecurityBlanket) { | 12 TEST(WMITest, TestLocalConnectionSecurityBlanket) { |
13 IWbemServices* services = NULL; | 13 IWbemServices* services = NULL; |
14 EXPECT_TRUE(WMI::CreateLocalConnection(true, &services)); | 14 EXPECT_TRUE(WMI::CreateLocalConnection(true, &services)); |
15 ASSERT_TRUE(NULL != services); | 15 ASSERT_TRUE(NULL != services); |
16 ULONG refs = services->Release(); | 16 ULONG refs = services->Release(); |
17 EXPECT_EQ(refs, 0); | 17 EXPECT_EQ(0u, refs); |
18 } | 18 } |
19 | 19 |
20 TEST(WMITest, TestLocalConnectionNoSecurityBlanket) { | 20 TEST(WMITest, TestLocalConnectionNoSecurityBlanket) { |
21 IWbemServices* services = NULL; | 21 IWbemServices* services = NULL; |
22 EXPECT_TRUE(WMI::CreateLocalConnection(false, &services)); | 22 EXPECT_TRUE(WMI::CreateLocalConnection(false, &services)); |
23 ASSERT_TRUE(NULL != services); | 23 ASSERT_TRUE(NULL != services); |
24 ULONG refs = services->Release(); | 24 ULONG refs = services->Release(); |
25 EXPECT_EQ(refs, 0); | 25 EXPECT_EQ(0u, refs); |
26 } | 26 } |
27 | 27 |
28 TEST(WMITest, TestCreateClassMethod) { | 28 TEST(WMITest, TestCreateClassMethod) { |
29 IWbemServices* wmi_services = NULL; | 29 IWbemServices* wmi_services = NULL; |
30 EXPECT_TRUE(WMI::CreateLocalConnection(true, &wmi_services)); | 30 EXPECT_TRUE(WMI::CreateLocalConnection(true, &wmi_services)); |
31 ASSERT_TRUE(NULL != wmi_services); | 31 ASSERT_TRUE(NULL != wmi_services); |
32 IWbemClassObject* class_method = NULL; | 32 IWbemClassObject* class_method = NULL; |
33 EXPECT_TRUE(WMI::CreateClassMethodObject(wmi_services, | 33 EXPECT_TRUE(WMI::CreateClassMethodObject(wmi_services, |
34 L"Win32_ShortcutFile", | 34 L"Win32_ShortcutFile", |
35 L"Rename", &class_method)); | 35 L"Rename", &class_method)); |
36 ASSERT_TRUE(NULL != class_method); | 36 ASSERT_TRUE(NULL != class_method); |
37 ULONG refs = class_method->Release(); | 37 ULONG refs = class_method->Release(); |
38 EXPECT_EQ(refs, 0); | 38 EXPECT_EQ(0u, refs); |
39 refs = wmi_services->Release(); | 39 refs = wmi_services->Release(); |
40 EXPECT_EQ(refs, 0); | 40 EXPECT_EQ(0u, refs); |
41 } | 41 } |
42 | 42 |
43 // Creates an instance of cmd which executes 'echo' and exits immediately. | 43 // Creates an instance of cmd which executes 'echo' and exits immediately. |
44 TEST(WMITest, TestLaunchProcess) { | 44 TEST(WMITest, TestLaunchProcess) { |
45 int pid = 0; | 45 int pid = 0; |
46 bool result = WMIProcess::Launch(L"cmd.exe /c echo excelent!", &pid); | 46 bool result = WMIProcess::Launch(L"cmd.exe /c echo excelent!", &pid); |
47 EXPECT_TRUE(result); | 47 EXPECT_TRUE(result); |
48 EXPECT_GT(pid, 0); | 48 EXPECT_GT(pid, 0); |
49 } | 49 } |
50 | 50 |
51 } // namespace installer | 51 } // namespace installer |
OLD | NEW |