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

Side by Side Diff: chrome/browser/extensions/external_registry_loader_win_unittest.cc

Issue 2796783002: [Ext Registry] Do not try to re-watch registry if we are already watching it. (Closed)
Patch Set: add test Created 3 years, 8 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/external_registry_loader_win.h"
6
7 #include "base/compiler_specific.h"
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/run_loop.h"
11 #include "content/public/test/test_browser_thread_bundle.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace extensions {
15
16 namespace {
17
18 class TestExternalRegistryLoader : public ExternalRegistryLoader {
19 public:
20 TestExternalRegistryLoader() {}
21
22 using ExternalRegistryLoader::StartLoading;
23
24 void WaitForTwoLoadsToFinished() {
25 // Run() returns immediately if Quit() has already been called.
26 run_loop_.Run();
27 }
28
29 private:
30 ~TestExternalRegistryLoader() override {}
31
32 void LoadFinished() {
33 ExternalRegistryLoader::LoadFinished();
34 ++load_finished_count_;
35 if (load_finished_count_ == 2)
36 run_loop_.Quit();
37 }
38
39 base::RunLoop run_loop_;
40 int load_finished_count_ = 0;
41
42 DISALLOW_COPY_AND_ASSIGN(TestExternalRegistryLoader);
43 };
44
45 } // namespace
46
47 class ExternalRegistryLoaderUnittest : public testing::Test {
48 public:
49 ExternalRegistryLoaderUnittest()
50 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
51 ~ExternalRegistryLoaderUnittest() override {}
52
53 private:
54 content::TestBrowserThreadBundle thread_bundle_;
55
56 DISALLOW_COPY_AND_ASSIGN(ExternalRegistryLoaderUnittest);
57 };
58
59 // Tests that calling StartLoading() more than once doesn't fail DCHECK.
60 // Regression test for https://crbug.com/653045.
61 TEST_F(ExternalRegistryLoaderUnittest, TwoStartLoadingDoesNotCrash) {
62 scoped_refptr<TestExternalRegistryLoader> test_loader =
63 make_scoped_refptr(new TestExternalRegistryLoader());
64
65 test_loader->StartLoading();
66 test_loader->StartLoading();
67
68 test_loader->WaitForTwoLoadsToFinished();
69 // Let registry watcher code complete.
70 base::RunLoop().RunUntilIdle();
71 }
72
73 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698