| OLD | NEW |
| 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" | |
| 12 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 13 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/test/test_browser_thread.h" | 13 #include "content/public/test/test_browser_thread.h" |
| 14 #include "content/public/test/test_browser_thread_bundle.h" |
| 15 #include "extensions/browser/api/declarative/test_rules_registry.h" | 15 #include "extensions/browser/api/declarative/test_rules_registry.h" |
| 16 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" | 16 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" |
| 17 #include "extensions/common/extension.h" | 17 #include "extensions/common/extension.h" |
| 18 #include "extensions/common/extension_builder.h" | 18 #include "extensions/common/extension_builder.h" |
| 19 #include "extensions/common/value_builder.h" | 19 #include "extensions/common/value_builder.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 const char kExtensionId[] = "foo"; | 23 const char kExtensionId[] = "foo"; |
| 24 | 24 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 registry->GetAllRules(kExtensionId, &get_rules); | 37 registry->GetAllRules(kExtensionId, &get_rules); |
| 38 EXPECT_EQ(expected_number_of_rules, get_rules.size()); | 38 EXPECT_EQ(expected_number_of_rules, get_rules.size()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 namespace extensions { | 43 namespace extensions { |
| 44 | 44 |
| 45 class RulesRegistryServiceTest : public testing::Test { | 45 class RulesRegistryServiceTest : public testing::Test { |
| 46 public: | 46 public: |
| 47 RulesRegistryServiceTest() | 47 RulesRegistryServiceTest() = default; |
| 48 : ui_(content::BrowserThread::UI, &message_loop_), | |
| 49 io_(content::BrowserThread::IO, &message_loop_) {} | |
| 50 | 48 |
| 51 ~RulesRegistryServiceTest() override {} | 49 ~RulesRegistryServiceTest() override {} |
| 52 | 50 |
| 53 void TearDown() override { | 51 void TearDown() override { |
| 54 // Make sure that deletion traits of all registries are executed. | 52 // Make sure that deletion traits of all registries are executed. |
| 55 base::RunLoop().RunUntilIdle(); | 53 base::RunLoop().RunUntilIdle(); |
| 56 } | 54 } |
| 57 | 55 |
| 58 protected: | 56 protected: |
| 59 base::MessageLoop message_loop_; | 57 content::TestBrowserThreadBundle test_browser_thread_bundle_; |
| 60 content::TestBrowserThread ui_; | |
| 61 content::TestBrowserThread io_; | |
| 62 }; | 58 }; |
| 63 | 59 |
| 64 TEST_F(RulesRegistryServiceTest, TestConstructionAndMultiThreading) { | 60 TEST_F(RulesRegistryServiceTest, TestConstructionAndMultiThreading) { |
| 65 RulesRegistryService registry_service(NULL); | 61 RulesRegistryService registry_service(NULL); |
| 66 | 62 |
| 67 int key = RulesRegistryService::kDefaultRulesRegistryID; | 63 int key = RulesRegistryService::kDefaultRulesRegistryID; |
| 68 TestRulesRegistry* ui_registry = | 64 TestRulesRegistry* ui_registry = |
| 69 new TestRulesRegistry(content::BrowserThread::UI, "ui", key); | 65 new TestRulesRegistry(content::BrowserThread::UI, "ui", key); |
| 70 | 66 |
| 71 TestRulesRegistry* io_registry = | 67 TestRulesRegistry* io_registry = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 118 |
| 123 content::BrowserThread::PostTask( | 119 content::BrowserThread::PostTask( |
| 124 content::BrowserThread::IO, FROM_HERE, | 120 content::BrowserThread::IO, FROM_HERE, |
| 125 base::BindOnce(&VerifyNumberOfRules, | 121 base::BindOnce(&VerifyNumberOfRules, |
| 126 registry_service.GetRulesRegistry(key, "io"), 0)); | 122 registry_service.GetRulesRegistry(key, "io"), 0)); |
| 127 | 123 |
| 128 base::RunLoop().RunUntilIdle(); | 124 base::RunLoop().RunUntilIdle(); |
| 129 } | 125 } |
| 130 | 126 |
| 131 } // namespace extensions | 127 } // namespace extensions |
| OLD | NEW |