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

Side by Side Diff: chrome/browser/extensions/extension_api_unittest.cc

Issue 789643004: Move chrome.alarms API from chrome/ to extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 10 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 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 "chrome/browser/extensions/extension_api_unittest.h" 5 #include "chrome/browser/extensions/extension_api_unittest.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/extension_function_test_utils.h" 8 #include "chrome/browser/extensions/extension_function_test_utils.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "extensions/browser/api_test_utils.h"
11 #include "content/public/browser/web_contents.h"
12 #include "content/public/common/url_constants.h"
13 #include "extensions/browser/extension_function.h" 11 #include "extensions/browser/extension_function.h"
14 #include "extensions/common/extension.h" 12 #include "extensions/common/extension.h"
15 #include "extensions/common/manifest.h" 13 #include "extensions/common/manifest.h"
16 #include "extensions/common/manifest_handlers/background_info.h" 14 #include "extensions/common/manifest_handlers/background_info.h"
17 15
18 namespace utils = extension_function_test_utils; 16 namespace utils = extension_function_test_utils;
19 17
20 namespace extensions { 18 namespace extensions {
21 19
22 ExtensionApiUnittest::ExtensionApiUnittest() : contents_(NULL) { 20 ExtensionApiUnittest::ExtensionApiUnittest() {
23 } 21 }
24 22
25 ExtensionApiUnittest::~ExtensionApiUnittest() { 23 ExtensionApiUnittest::~ExtensionApiUnittest() {
26 } 24 }
27 25
28 void ExtensionApiUnittest::SetUp() { 26 void ExtensionApiUnittest::SetUp() {
29 BrowserWithTestWindowTest::SetUp(); 27 BrowserWithTestWindowTest::SetUp();
30 extension_ = utils::CreateEmptyExtensionWithLocation(Manifest::UNPACKED); 28 extension_ = api_test_utils::CreateEmptyExtensionWithLocation(
31 } 29 Manifest::UNPACKED);
32
33 void ExtensionApiUnittest::CreateBackgroundPage() {
34 if (!contents_) {
35 GURL url = BackgroundInfo::GetBackgroundURL(extension());
36 if (url.is_empty())
37 url = GURL(url::kAboutBlankURL);
38 AddTab(browser(), url);
39 contents_ = browser()->tab_strip_model()->GetActiveWebContents();
40 }
41 } 30 }
42 31
43 scoped_ptr<base::Value> ExtensionApiUnittest::RunFunctionAndReturnValue( 32 scoped_ptr<base::Value> ExtensionApiUnittest::RunFunctionAndReturnValue(
44 UIThreadExtensionFunction* function, const std::string& args) { 33 UIThreadExtensionFunction* function, const std::string& args) {
45 function->set_extension(extension()); 34 function->set_extension(extension());
46 if (contents_)
47 function->SetRenderViewHost(contents_->GetRenderViewHost());
48 return scoped_ptr<base::Value>( 35 return scoped_ptr<base::Value>(
49 utils::RunFunctionAndReturnSingleResult(function, args, browser())); 36 utils::RunFunctionAndReturnSingleResult(function, args, browser()));
50 } 37 }
51 38
52 scoped_ptr<base::DictionaryValue> 39 scoped_ptr<base::DictionaryValue>
53 ExtensionApiUnittest::RunFunctionAndReturnDictionary( 40 ExtensionApiUnittest::RunFunctionAndReturnDictionary(
54 UIThreadExtensionFunction* function, const std::string& args) { 41 UIThreadExtensionFunction* function, const std::string& args) {
55 base::Value* value = RunFunctionAndReturnValue(function, args).release(); 42 base::Value* value = RunFunctionAndReturnValue(function, args).release();
56 base::DictionaryValue* dict = NULL; 43 base::DictionaryValue* dict = NULL;
57 44
(...skipping 16 matching lines...) Expand all
74 61
75 // We expect to either have successfuly retrieved a list from the value, 62 // We expect to either have successfuly retrieved a list from the value,
76 // or the value to have been NULL. 63 // or the value to have been NULL.
77 EXPECT_TRUE(list); 64 EXPECT_TRUE(list);
78 return scoped_ptr<base::ListValue>(list); 65 return scoped_ptr<base::ListValue>(list);
79 } 66 }
80 67
81 std::string ExtensionApiUnittest::RunFunctionAndReturnError( 68 std::string ExtensionApiUnittest::RunFunctionAndReturnError(
82 UIThreadExtensionFunction* function, const std::string& args) { 69 UIThreadExtensionFunction* function, const std::string& args) {
83 function->set_extension(extension()); 70 function->set_extension(extension());
84 if (contents_)
85 function->SetRenderViewHost(contents_->GetRenderViewHost());
86 return utils::RunFunctionAndReturnError(function, args, browser()); 71 return utils::RunFunctionAndReturnError(function, args, browser());
87 } 72 }
88 73
89 void ExtensionApiUnittest::RunFunction( 74 void ExtensionApiUnittest::RunFunction(
90 UIThreadExtensionFunction* function, const std::string& args) { 75 UIThreadExtensionFunction* function, const std::string& args) {
91 RunFunctionAndReturnValue(function, args); 76 RunFunctionAndReturnValue(function, args);
92 } 77 }
93 78
94 } // namespace extensions 79 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_api_unittest.h ('k') | chrome/browser/extensions/extension_function_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698