OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/browser/conflicts/module_database_win.h" | 5 #include "chrome/browser/conflicts/module_database_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/test/scoped_task_scheduler.h" | 14 #include "base/test/scoped_task_environment.h" |
15 #include "base/threading/sequenced_task_runner_handle.h" | 15 #include "base/threading/sequenced_task_runner_handle.h" |
16 #include "base/threading/simple_thread.h" | 16 #include "base/threading/simple_thread.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // A simple mechanism for running a single task on a separate thread. | 21 // A simple mechanism for running a single task on a separate thread. |
22 class SingleTaskRunner : public base::SimpleThread { | 22 class SingleTaskRunner : public base::SimpleThread { |
23 public: | 23 public: |
24 explicit SingleTaskRunner(base::Closure task) | 24 explicit SingleTaskRunner(base::Closure task) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return std::count_if( | 105 return std::count_if( |
106 load_addresses.begin(), load_addresses.end(), | 106 load_addresses.begin(), load_addresses.end(), |
107 [module_id](const auto& x) { return module_id == x.first; }); | 107 [module_id](const auto& x) { return module_id == x.first; }); |
108 } | 108 } |
109 | 109 |
110 const base::FilePath dll1_; | 110 const base::FilePath dll1_; |
111 const base::FilePath dll2_; | 111 const base::FilePath dll2_; |
112 | 112 |
113 private: | 113 private: |
114 // Must be before |module_database_|. | 114 // Must be before |module_database_|. |
115 base::test::ScopedTaskScheduler scoped_task_scheduler_; | 115 base::test::ScopedTaskEnvironment scoped_task_environment_; |
116 | 116 |
117 std::unique_ptr<ModuleDatabase> module_database_; | 117 std::unique_ptr<ModuleDatabase> module_database_; |
118 | 118 |
119 DISALLOW_COPY_AND_ASSIGN(ModuleDatabaseTest); | 119 DISALLOW_COPY_AND_ASSIGN(ModuleDatabaseTest); |
120 }; | 120 }; |
121 | 121 |
122 TEST_F(ModuleDatabaseTest, LoadAddressVectorOperations) { | 122 TEST_F(ModuleDatabaseTest, LoadAddressVectorOperations) { |
123 using TMD = TestModuleDatabase; | 123 using TMD = TestModuleDatabase; |
124 TMD::ModuleLoadAddresses la; | 124 TMD::ModuleLoadAddresses la; |
125 | 125 |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 // End the first process without an explicit unload. This invalidates |p1|. | 522 // End the first process without an explicit unload. This invalidates |p1|. |
523 module_database()->OnProcessEnded(kPid1, kCreateTime1); | 523 module_database()->OnProcessEnded(kPid1, kCreateTime1); |
524 EXPECT_EQ(2u, modules().size()); | 524 EXPECT_EQ(2u, modules().size()); |
525 EXPECT_EQ(0u, processes().size()); | 525 EXPECT_EQ(0u, processes().size()); |
526 EXPECT_EQ(ProcessTypeToBit(content::PROCESS_TYPE_BROWSER) | | 526 EXPECT_EQ(ProcessTypeToBit(content::PROCESS_TYPE_BROWSER) | |
527 ProcessTypeToBit(content::PROCESS_TYPE_RENDERER), | 527 ProcessTypeToBit(content::PROCESS_TYPE_RENDERER), |
528 m1->second.process_types); | 528 m1->second.process_types); |
529 EXPECT_EQ(ProcessTypeToBit(content::PROCESS_TYPE_BROWSER), | 529 EXPECT_EQ(ProcessTypeToBit(content::PROCESS_TYPE_BROWSER), |
530 m2->second.process_types); | 530 m2->second.process_types); |
531 } | 531 } |
OLD | NEW |