Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: chrome/common/conflicts/module_watcher_win_unittest.cc

Issue 2576843002: [win] Create ModuleDatabase and ModuleEventSinkImpl. (Closed)
Patch Set: Fix small bug. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/conflicts/module_watcher_win.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/common/conflicts/module_watcher_win.h" 5 #include "chrome/common/conflicts/module_watcher_win.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 class ModuleWatcherTest : public testing::Test { 12 class ModuleWatcherTest : public testing::Test {
13 public: 13 protected:
14 ModuleWatcherTest() 14 ModuleWatcherTest()
15 : module_(nullptr), 15 : module_(nullptr),
16 module_event_count_(0), 16 module_event_count_(0),
17 module_already_loaded_event_count_(0), 17 module_already_loaded_event_count_(0),
18 module_loaded_event_count_(0), 18 module_loaded_event_count_(0),
19 module_unloaded_event_count_(0) {} 19 module_unloaded_event_count_(0) {}
20 20
21 void OnModuleEvent(const mojom::ModuleEvent& event) { 21 void OnModuleEvent(const ModuleWatcher::ModuleEvent& event) {
22 ++module_event_count_; 22 ++module_event_count_;
23 switch (event.event_type) { 23 switch (event.event_type) {
24 case mojom::ModuleEventType::MODULE_ALREADY_LOADED: 24 case mojom::ModuleEventType::MODULE_ALREADY_LOADED:
25 ++module_already_loaded_event_count_; 25 ++module_already_loaded_event_count_;
26 break; 26 break;
27 case mojom::ModuleEventType::MODULE_LOADED: 27 case mojom::ModuleEventType::MODULE_LOADED:
28 ++module_loaded_event_count_; 28 ++module_loaded_event_count_;
29 break; 29 break;
30 case mojom::ModuleEventType::MODULE_UNLOADED: 30 case mojom::ModuleEventType::MODULE_UNLOADED:
31 ++module_unloaded_event_count_; 31 ++module_unloaded_event_count_;
(...skipping 24 matching lines...) Expand all
56 module_ = nullptr; 56 module_ = nullptr;
57 } 57 }
58 58
59 std::unique_ptr<ModuleWatcher> Create() { 59 std::unique_ptr<ModuleWatcher> Create() {
60 return ModuleWatcher::Create( 60 return ModuleWatcher::Create(
61 base::Bind(&ModuleWatcherTest::OnModuleEvent, base::Unretained(this))); 61 base::Bind(&ModuleWatcherTest::OnModuleEvent, base::Unretained(this)));
62 } 62 }
63 63
64 // Holds a handle to a loaded module. 64 // Holds a handle to a loaded module.
65 HMODULE module_; 65 HMODULE module_;
66
67 // Total number of module events seen. 66 // Total number of module events seen.
68 int module_event_count_; 67 int module_event_count_;
69 // Total number of MODULE_ALREADY_LOADED events seen. 68 // Total number of MODULE_ALREADY_LOADED events seen.
70 int module_already_loaded_event_count_; 69 int module_already_loaded_event_count_;
71 // Total number of MODULE_LOADED events seen. 70 // Total number of MODULE_LOADED events seen.
72 int module_loaded_event_count_; 71 int module_loaded_event_count_;
73 // Total number of MODULE_UNLOADED events seen. 72 // Total number of MODULE_UNLOADED events seen.
74 int module_unloaded_event_count_; 73 int module_unloaded_event_count_;
75 74
76 private: 75 private:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 EXPECT_LT(previous_module_loaded_event_count, module_loaded_event_count_); 109 EXPECT_LT(previous_module_loaded_event_count, module_loaded_event_count_);
111 110
112 // Destroy the module watcher. 111 // Destroy the module watcher.
113 mw.reset(); 112 mw.reset();
114 113
115 // Unload the module and ensure no notification is received this time. 114 // Unload the module and ensure no notification is received this time.
116 previous_module_unloaded_event_count = module_unloaded_event_count_; 115 previous_module_unloaded_event_count = module_unloaded_event_count_;
117 UnloadModule(); 116 UnloadModule();
118 EXPECT_EQ(previous_module_unloaded_event_count, module_unloaded_event_count_); 117 EXPECT_EQ(previous_module_unloaded_event_count, module_unloaded_event_count_);
119 } 118 }
OLDNEW
« no previous file with comments | « chrome/common/conflicts/module_watcher_win.cc ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698