OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/installer/util/legacy_firewall_manager_win.h" | 5 #include "chrome/installer/util/legacy_firewall_manager_win.h" |
6 | 6 |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/process/process_handle.h" | 8 #include "base/process/process_info.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace installer { | 11 namespace installer { |
12 | 12 |
13 class LegacyFirewallManagerTest : public ::testing::Test { | 13 class LegacyFirewallManagerTest : public ::testing::Test { |
14 public: | 14 public: |
15 LegacyFirewallManagerTest() : skip_test_(true) {} | 15 LegacyFirewallManagerTest() : skip_test_(true) {} |
16 | 16 |
17 protected: | 17 protected: |
18 // Sets up the test fixture. | 18 // Sets up the test fixture. |
19 virtual void SetUp() override { | 19 virtual void SetUp() override { |
20 base::IntegrityLevel level = base::INTEGRITY_UNKNOWN; | 20 if (base::GetCurrentProcessIntegrityLevel() != base::HIGH_INTEGRITY) { |
21 if (GetProcessIntegrityLevel(base::GetCurrentProcessHandle(), &level) && | |
22 level != base::HIGH_INTEGRITY) { | |
23 LOG(WARNING) << "Not elevated. Skipping the test."; | 21 LOG(WARNING) << "Not elevated. Skipping the test."; |
24 return; | 22 return; |
25 }; | 23 }; |
26 skip_test_ = false; | 24 skip_test_ = false; |
27 base::FilePath exe_path; | 25 base::FilePath exe_path; |
28 PathService::Get(base::FILE_EXE, &exe_path); | 26 PathService::Get(base::FILE_EXE, &exe_path); |
29 EXPECT_TRUE(manager_.Init(L"LegacyFirewallManagerTest", exe_path)); | 27 EXPECT_TRUE(manager_.Init(L"LegacyFirewallManagerTest", exe_path)); |
30 manager_.DeleteRule(); | 28 manager_.DeleteRule(); |
31 } | 29 } |
32 | 30 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 return; | 63 return; |
66 EXPECT_TRUE(manager_.SetAllowIncomingConnection(false)); | 64 EXPECT_TRUE(manager_.SetAllowIncomingConnection(false)); |
67 bool allowed = true; | 65 bool allowed = true; |
68 EXPECT_TRUE(manager_.GetAllowIncomingConnection(&allowed)); | 66 EXPECT_TRUE(manager_.GetAllowIncomingConnection(&allowed)); |
69 EXPECT_FALSE(allowed); | 67 EXPECT_FALSE(allowed); |
70 manager_.DeleteRule(); | 68 manager_.DeleteRule(); |
71 EXPECT_FALSE(manager_.GetAllowIncomingConnection(NULL)); | 69 EXPECT_FALSE(manager_.GetAllowIncomingConnection(NULL)); |
72 } | 70 } |
73 | 71 |
74 } // namespace installer | 72 } // namespace installer |
OLD | NEW |