| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_unittest.h" | 5 #include "extensions/browser/api_unittest.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "components/user_prefs/user_prefs.h" | 8 #include "components/user_prefs/user_prefs.h" |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 ApiUnitTest::~ApiUnitTest() { | 37 ApiUnitTest::~ApiUnitTest() { |
| 38 } | 38 } |
| 39 | 39 |
| 40 void ApiUnitTest::SetUp() { | 40 void ApiUnitTest::SetUp() { |
| 41 ExtensionsTest::SetUp(); | 41 ExtensionsTest::SetUp(); |
| 42 | 42 |
| 43 thread_bundle_.reset(new content::TestBrowserThreadBundle( | 43 thread_bundle_.reset(new content::TestBrowserThreadBundle( |
| 44 content::TestBrowserThreadBundle::DEFAULT)); | 44 content::TestBrowserThreadBundle::DEFAULT)); |
| 45 user_prefs::UserPrefs::Set(browser_context(), &testing_pref_service_); | 45 user_prefs::UserPrefs::Set(browser_context(), &testing_pref_service_); |
| 46 | 46 |
| 47 extension_ = | 47 extension_ = ExtensionBuilder() |
| 48 ExtensionBuilder() | 48 .SetManifest(DictionaryBuilder() |
| 49 .SetManifest(std::move( | 49 .Set("name", "Test") |
| 50 DictionaryBuilder().Set("name", "Test").Set("version", "1.0"))) | 50 .Set("version", "1.0") |
| 51 .SetLocation(Manifest::UNPACKED) | 51 .Build()) |
| 52 .Build(); | 52 .SetLocation(Manifest::UNPACKED) |
| 53 .Build(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void ApiUnitTest::CreateBackgroundPage() { | 56 void ApiUnitTest::CreateBackgroundPage() { |
| 56 if (!contents_) { | 57 if (!contents_) { |
| 57 GURL url = BackgroundInfo::GetBackgroundURL(extension()); | 58 GURL url = BackgroundInfo::GetBackgroundURL(extension()); |
| 58 if (url.is_empty()) | 59 if (url.is_empty()) |
| 59 url = GURL(url::kAboutBlankURL); | 60 url = GURL(url::kAboutBlankURL); |
| 60 content::SiteInstance* site_instance = | 61 content::SiteInstance* site_instance = |
| 61 content::SiteInstance::CreateForURL(browser_context(), url); | 62 content::SiteInstance::CreateForURL(browser_context(), url); |
| 62 contents_.reset(content::WebContents::Create( | 63 contents_.reset(content::WebContents::Create( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 function->SetRenderFrameHost(contents_->GetMainFrame()); | 113 function->SetRenderFrameHost(contents_->GetMainFrame()); |
| 113 return utils::RunFunctionAndReturnError(function, args, browser_context()); | 114 return utils::RunFunctionAndReturnError(function, args, browser_context()); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void ApiUnitTest::RunFunction(UIThreadExtensionFunction* function, | 117 void ApiUnitTest::RunFunction(UIThreadExtensionFunction* function, |
| 117 const std::string& args) { | 118 const std::string& args) { |
| 118 RunFunctionAndReturnValue(function, args); | 119 RunFunctionAndReturnValue(function, args); |
| 119 } | 120 } |
| 120 | 121 |
| 121 } // namespace extensions | 122 } // namespace extensions |
| OLD | NEW |