| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/extensions/extension_process_manager.h" | 5 #include "chrome/browser/extensions/extension_process_manager.h" |
| 6 #include "chrome/browser/renderer_host/site_instance.h" | 6 #include "chrome/browser/renderer_host/site_instance.h" |
| 7 #include "chrome/common/extensions/extension_error_reporter.h" | 7 #include "chrome/common/extensions/extension_error_reporter.h" |
| 8 #include "chrome/test/testing_profile.h" | 8 #include "chrome/test/testing_profile.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 // make the test a PlatformTest to setup autorelease pools properly on mac | 14 // make the test a PlatformTest to setup autorelease pools properly on mac |
| 15 class ExtensionProcessManagerTest : public testing::Test { | 15 class ExtensionProcessManagerTest : public testing::Test { |
| 16 public: | 16 public: |
| 17 static void SetUpTestCase() { | 17 static void SetUpTestCase() { |
| 18 ExtensionErrorReporter::Init(false); // no noisy errors | 18 ExtensionErrorReporter::Init(false); // no noisy errors |
| 19 } | 19 } |
| 20 | 20 |
| 21 virtual void SetUp() { | 21 virtual void SetUp() { |
| 22 ExtensionErrorReporter::GetInstance()->ClearErrors(); | 22 ExtensionErrorReporter::GetInstance()->ClearErrors(); |
| 23 } | 23 } |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 } | 26 } // namespace |
| 27 | 27 |
| 28 // Test that extensions get grouped in the right SiteInstance (and therefore | 28 // Test that extensions get grouped in the right SiteInstance (and therefore |
| 29 // process) based on their URLs. | 29 // process) based on their URLs. |
| 30 TEST_F(ExtensionProcessManagerTest, ProcessGrouping) { | 30 TEST_F(ExtensionProcessManagerTest, ProcessGrouping) { |
| 31 // Extensions in different profiles should always be different SiteInstances. | 31 // Extensions in different profiles should always be different SiteInstances. |
| 32 // Note: we don't initialize these, since we're not testing that | 32 // Note: we don't initialize these, since we're not testing that |
| 33 // functionality. This means we can get away with a NULL UserScriptMaster. | 33 // functionality. This means we can get away with a NULL UserScriptMaster. |
| 34 TestingProfile profile1(1); | 34 TestingProfile profile1(1); |
| 35 scoped_ptr<ExtensionProcessManager> manager1( | 35 scoped_ptr<ExtensionProcessManager> manager1( |
| 36 new ExtensionProcessManager(&profile1)); | 36 new ExtensionProcessManager(&profile1)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 52 EXPECT_EQ(site11, site12); | 52 EXPECT_EQ(site11, site12); |
| 53 | 53 |
| 54 scoped_refptr<SiteInstance> site21 = | 54 scoped_refptr<SiteInstance> site21 = |
| 55 manager1->GetSiteInstanceForURL(ext2_url1); | 55 manager1->GetSiteInstanceForURL(ext2_url1); |
| 56 EXPECT_NE(site11, site21); | 56 EXPECT_NE(site11, site21); |
| 57 | 57 |
| 58 scoped_refptr<SiteInstance> other_profile_site = | 58 scoped_refptr<SiteInstance> other_profile_site = |
| 59 manager2->GetSiteInstanceForURL(ext1_url1); | 59 manager2->GetSiteInstanceForURL(ext1_url1); |
| 60 EXPECT_NE(site11, other_profile_site); | 60 EXPECT_NE(site11, other_profile_site); |
| 61 } | 61 } |
| OLD | NEW |