| 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/advanced_firewall_manager_win.h" | 5 #include "chrome/installer/util/advanced_firewall_manager_win.h" |
| 6 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/process/process_info.h" | 8 #include "base/process/process_info.h" |
| 9 #include "base/win/scoped_bstr.h" | 9 #include "base/win/scoped_bstr.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace installer { | 12 namespace installer { |
| 13 | 13 |
| 14 class AdvancedFirewallManagerTest : public ::testing::Test { | 14 class AdvancedFirewallManagerTest : public ::testing::Test { |
| 15 public: | 15 public: |
| 16 AdvancedFirewallManagerTest() : skip_test_(true) {} | 16 AdvancedFirewallManagerTest() : skip_test_(true) {} |
| 17 | 17 |
| 18 protected: | 18 protected: |
| 19 // Sets up the test fixture. | 19 // Sets up the test fixture. |
| 20 virtual void SetUp() override { | 20 void SetUp() override { |
| 21 if (base::GetCurrentProcessIntegrityLevel() != base::HIGH_INTEGRITY) { | 21 if (base::GetCurrentProcessIntegrityLevel() != base::HIGH_INTEGRITY) { |
| 22 LOG(WARNING) << "XP or not elevated. Skipping the test."; | 22 LOG(WARNING) << "XP or not elevated. Skipping the test."; |
| 23 return; | 23 return; |
| 24 }; | 24 } |
| 25 skip_test_ = false; | 25 skip_test_ = false; |
| 26 base::FilePath exe_path; | 26 base::FilePath exe_path; |
| 27 PathService::Get(base::FILE_EXE, &exe_path); | 27 PathService::Get(base::FILE_EXE, &exe_path); |
| 28 EXPECT_TRUE(manager_.Init(L"AdvancedFirewallManagerTest", exe_path)); | 28 EXPECT_TRUE(manager_.Init(L"AdvancedFirewallManagerTest", exe_path)); |
| 29 manager_.DeleteAllRules(); | 29 manager_.DeleteAllRules(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 // Tears down the test fixture. | 32 // Tears down the test fixture. |
| 33 virtual void TearDown() override { | 33 void TearDown() override { |
| 34 if (!skip_test_) | 34 if (!skip_test_) |
| 35 manager_.DeleteAllRules(); | 35 manager_.DeleteAllRules(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Forwards calls to |manager_| to avoid making each test a friend of | 38 // Forwards calls to |manager_| to avoid making each test a friend of |
| 39 // |AdvancedFirewallManager|. | 39 // |AdvancedFirewallManager|. |
| 40 void GetAllRules(std::vector<base::string16>* rule_names) { | 40 void GetAllRules(std::vector<base::string16>* rule_names) { |
| 41 std::vector<base::win::ScopedComPtr<INetFwRule> > rules; | 41 std::vector<base::win::ScopedComPtr<INetFwRule> > rules; |
| 42 manager_.GetAllRules(&rules); | 42 manager_.GetAllRules(&rules); |
| 43 for (size_t i = 0; i < rules.size(); ++i) { | 43 for (size_t i = 0; i < rules.size(); ++i) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 EXPECT_TRUE(manager_.HasAnyRule()); | 76 EXPECT_TRUE(manager_.HasAnyRule()); |
| 77 | 77 |
| 78 manager_.DeleteRuleByName(kRuleName); | 78 manager_.DeleteRuleByName(kRuleName); |
| 79 rule_names.clear(); | 79 rule_names.clear(); |
| 80 GetAllRules(&rule_names); | 80 GetAllRules(&rule_names); |
| 81 EXPECT_TRUE(rule_names.empty()); | 81 EXPECT_TRUE(rule_names.empty()); |
| 82 EXPECT_FALSE(manager_.HasAnyRule()); | 82 EXPECT_FALSE(manager_.HasAnyRule()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace installer | 85 } // namespace installer |
| OLD | NEW |