| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 extension_ = ExtensionBuilder() | 47 extension_ = ExtensionBuilder() |
| 48 .SetManifest(DictionaryBuilder() | 48 .SetManifest(DictionaryBuilder() |
| 49 .Set("name", "Test") | 49 .Set("name", "Test") |
| 50 .Set("version", "1.0") | 50 .Set("version", "1.0") |
| 51 .Build()) | 51 .Build()) |
| 52 .SetLocation(Manifest::UNPACKED) | 52 .SetLocation(Manifest::UNPACKED) |
| 53 .Build(); | 53 .Build(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ApiUnitTest::TearDown() { |
| 57 extension_ = nullptr; |
| 58 contents_.reset(); |
| 59 ExtensionsTest::TearDown(); |
| 60 } |
| 61 |
| 56 void ApiUnitTest::CreateBackgroundPage() { | 62 void ApiUnitTest::CreateBackgroundPage() { |
| 57 if (!contents_) { | 63 if (!contents_) { |
| 58 GURL url = BackgroundInfo::GetBackgroundURL(extension()); | 64 GURL url = BackgroundInfo::GetBackgroundURL(extension()); |
| 59 if (url.is_empty()) | 65 if (url.is_empty()) |
| 60 url = GURL(url::kAboutBlankURL); | 66 url = GURL(url::kAboutBlankURL); |
| 61 contents_.reset( | 67 contents_.reset( |
| 62 content::WebContents::Create(content::WebContents::CreateParams( | 68 content::WebContents::Create(content::WebContents::CreateParams( |
| 63 browser_context(), | 69 browser_context(), |
| 64 content::SiteInstance::CreateForURL(browser_context(), url)))); | 70 content::SiteInstance::CreateForURL(browser_context(), url)))); |
| 65 } | 71 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 function->SetRenderFrameHost(contents_->GetMainFrame()); | 119 function->SetRenderFrameHost(contents_->GetMainFrame()); |
| 114 return utils::RunFunctionAndReturnError(function, args, browser_context()); | 120 return utils::RunFunctionAndReturnError(function, args, browser_context()); |
| 115 } | 121 } |
| 116 | 122 |
| 117 void ApiUnitTest::RunFunction(UIThreadExtensionFunction* function, | 123 void ApiUnitTest::RunFunction(UIThreadExtensionFunction* function, |
| 118 const std::string& args) { | 124 const std::string& args) { |
| 119 RunFunctionAndReturnValue(function, args); | 125 RunFunctionAndReturnValue(function, args); |
| 120 } | 126 } |
| 121 | 127 |
| 122 } // namespace extensions | 128 } // namespace extensions |
| OLD | NEW |