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

Side by Side Diff: chrome/browser/extensions/api/declarative/rules_registry_service_unittest.cc

Issue 2083363002: Remove calls to deprecated MessageLoop methods in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/browser/api/declarative/rules_registry_service.h" 5 #include "extensions/browser/api/declarative/rules_registry_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/run_loop.h"
12 #include "chrome/test/base/testing_profile.h" 13 #include "chrome/test/base/testing_profile.h"
13 #include "content/public/test/test_browser_thread.h" 14 #include "content/public/test/test_browser_thread.h"
14 #include "extensions/browser/api/declarative/test_rules_registry.h" 15 #include "extensions/browser/api/declarative/test_rules_registry.h"
15 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" 16 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h"
16 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
17 #include "extensions/common/extension_builder.h" 18 #include "extensions/common/extension_builder.h"
18 #include "extensions/common/value_builder.h" 19 #include "extensions/common/value_builder.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace { 22 namespace {
(...skipping 22 matching lines...) Expand all
44 class RulesRegistryServiceTest : public testing::Test { 45 class RulesRegistryServiceTest : public testing::Test {
45 public: 46 public:
46 RulesRegistryServiceTest() 47 RulesRegistryServiceTest()
47 : ui_(content::BrowserThread::UI, &message_loop_), 48 : ui_(content::BrowserThread::UI, &message_loop_),
48 io_(content::BrowserThread::IO, &message_loop_) {} 49 io_(content::BrowserThread::IO, &message_loop_) {}
49 50
50 ~RulesRegistryServiceTest() override {} 51 ~RulesRegistryServiceTest() override {}
51 52
52 void TearDown() override { 53 void TearDown() override {
53 // Make sure that deletion traits of all registries are executed. 54 // Make sure that deletion traits of all registries are executed.
54 message_loop_.RunUntilIdle(); 55 base::RunLoop().RunUntilIdle();
55 } 56 }
56 57
57 protected: 58 protected:
58 base::MessageLoop message_loop_; 59 base::MessageLoop message_loop_;
59 content::TestBrowserThread ui_; 60 content::TestBrowserThread ui_;
60 content::TestBrowserThread io_; 61 content::TestBrowserThread io_;
61 }; 62 };
62 63
63 TEST_F(RulesRegistryServiceTest, TestConstructionAndMultiThreading) { 64 TEST_F(RulesRegistryServiceTest, TestConstructionAndMultiThreading) {
64 RulesRegistryService registry_service(NULL); 65 RulesRegistryService registry_service(NULL);
(...skipping 27 matching lines...) Expand all
92 content::BrowserThread::PostTask( 93 content::BrowserThread::PostTask(
93 content::BrowserThread::UI, FROM_HERE, 94 content::BrowserThread::UI, FROM_HERE,
94 base::Bind(&VerifyNumberOfRules, 95 base::Bind(&VerifyNumberOfRules,
95 registry_service.GetRulesRegistry(key, "ui"), 1)); 96 registry_service.GetRulesRegistry(key, "ui"), 1));
96 97
97 content::BrowserThread::PostTask( 98 content::BrowserThread::PostTask(
98 content::BrowserThread::IO, FROM_HERE, 99 content::BrowserThread::IO, FROM_HERE,
99 base::Bind(&VerifyNumberOfRules, 100 base::Bind(&VerifyNumberOfRules,
100 registry_service.GetRulesRegistry(key, "io"), 1)); 101 registry_service.GetRulesRegistry(key, "io"), 1));
101 102
102 message_loop_.RunUntilIdle(); 103 base::RunLoop().RunUntilIdle();
103 104
104 // Test extension uninstalling. 105 // Test extension uninstalling.
105 std::unique_ptr<base::DictionaryValue> manifest = 106 std::unique_ptr<base::DictionaryValue> manifest =
106 DictionaryBuilder() 107 DictionaryBuilder()
107 .Set("name", "Extension") 108 .Set("name", "Extension")
108 .Set("version", "1.0") 109 .Set("version", "1.0")
109 .Set("manifest_version", 2) 110 .Set("manifest_version", 2)
110 .Build(); 111 .Build();
111 scoped_refptr<Extension> extension = ExtensionBuilder() 112 scoped_refptr<Extension> extension = ExtensionBuilder()
112 .SetManifest(std::move(manifest)) 113 .SetManifest(std::move(manifest))
113 .SetID(kExtensionId) 114 .SetID(kExtensionId)
114 .Build(); 115 .Build();
115 registry_service.SimulateExtensionUninstalled(extension.get()); 116 registry_service.SimulateExtensionUninstalled(extension.get());
116 117
117 content::BrowserThread::PostTask( 118 content::BrowserThread::PostTask(
118 content::BrowserThread::UI, FROM_HERE, 119 content::BrowserThread::UI, FROM_HERE,
119 base::Bind(&VerifyNumberOfRules, 120 base::Bind(&VerifyNumberOfRules,
120 registry_service.GetRulesRegistry(key, "ui"), 0)); 121 registry_service.GetRulesRegistry(key, "ui"), 0));
121 122
122 content::BrowserThread::PostTask( 123 content::BrowserThread::PostTask(
123 content::BrowserThread::IO, FROM_HERE, 124 content::BrowserThread::IO, FROM_HERE,
124 base::Bind(&VerifyNumberOfRules, 125 base::Bind(&VerifyNumberOfRules,
125 registry_service.GetRulesRegistry(key, "io"), 0)); 126 registry_service.GetRulesRegistry(key, "io"), 0));
126 127
127 message_loop_.RunUntilIdle(); 128 base::RunLoop().RunUntilIdle();
128 } 129 }
129 130
130 } // namespace extensions 131 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698