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 "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 "extensions/browser/api_test_utils.h" | 10 #include "extensions/browser/api_test_utils.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 ExtensionApiUnittest::~ExtensionApiUnittest() { | 23 ExtensionApiUnittest::~ExtensionApiUnittest() { |
24 } | 24 } |
25 | 25 |
26 void ExtensionApiUnittest::SetUp() { | 26 void ExtensionApiUnittest::SetUp() { |
27 BrowserWithTestWindowTest::SetUp(); | 27 BrowserWithTestWindowTest::SetUp(); |
28 extension_ = api_test_utils::CreateEmptyExtensionWithLocation( | 28 extension_ = api_test_utils::CreateEmptyExtensionWithLocation( |
29 Manifest::UNPACKED); | 29 Manifest::UNPACKED); |
30 } | 30 } |
31 | 31 |
32 scoped_ptr<base::Value> ExtensionApiUnittest::RunFunctionAndReturnValue( | 32 std::unique_ptr<base::Value> ExtensionApiUnittest::RunFunctionAndReturnValue( |
33 UIThreadExtensionFunction* function, const std::string& args) { | 33 UIThreadExtensionFunction* function, |
| 34 const std::string& args) { |
34 function->set_extension(extension()); | 35 function->set_extension(extension()); |
35 return scoped_ptr<base::Value>( | 36 return std::unique_ptr<base::Value>( |
36 utils::RunFunctionAndReturnSingleResult(function, args, browser())); | 37 utils::RunFunctionAndReturnSingleResult(function, args, browser())); |
37 } | 38 } |
38 | 39 |
39 scoped_ptr<base::DictionaryValue> | 40 std::unique_ptr<base::DictionaryValue> |
40 ExtensionApiUnittest::RunFunctionAndReturnDictionary( | 41 ExtensionApiUnittest::RunFunctionAndReturnDictionary( |
41 UIThreadExtensionFunction* function, const std::string& args) { | 42 UIThreadExtensionFunction* function, |
| 43 const std::string& args) { |
42 base::Value* value = RunFunctionAndReturnValue(function, args).release(); | 44 base::Value* value = RunFunctionAndReturnValue(function, args).release(); |
43 base::DictionaryValue* dict = NULL; | 45 base::DictionaryValue* dict = NULL; |
44 | 46 |
45 if (value && !value->GetAsDictionary(&dict)) | 47 if (value && !value->GetAsDictionary(&dict)) |
46 delete value; | 48 delete value; |
47 | 49 |
48 // We expect to either have successfuly retrieved a dictionary from the value, | 50 // We expect to either have successfuly retrieved a dictionary from the value, |
49 // or the value to have been NULL. | 51 // or the value to have been NULL. |
50 EXPECT_TRUE(dict || !value); | 52 EXPECT_TRUE(dict || !value); |
51 return scoped_ptr<base::DictionaryValue>(dict); | 53 return std::unique_ptr<base::DictionaryValue>(dict); |
52 } | 54 } |
53 | 55 |
54 scoped_ptr<base::ListValue> ExtensionApiUnittest::RunFunctionAndReturnList( | 56 std::unique_ptr<base::ListValue> ExtensionApiUnittest::RunFunctionAndReturnList( |
55 UIThreadExtensionFunction* function, const std::string& args) { | 57 UIThreadExtensionFunction* function, |
| 58 const std::string& args) { |
56 base::Value* value = RunFunctionAndReturnValue(function, args).release(); | 59 base::Value* value = RunFunctionAndReturnValue(function, args).release(); |
57 base::ListValue* list = NULL; | 60 base::ListValue* list = NULL; |
58 | 61 |
59 if (value && !value->GetAsList(&list)) | 62 if (value && !value->GetAsList(&list)) |
60 delete value; | 63 delete value; |
61 | 64 |
62 // We expect to either have successfuly retrieved a list from the value, | 65 // We expect to either have successfuly retrieved a list from the value, |
63 // or the value to have been NULL. | 66 // or the value to have been NULL. |
64 EXPECT_TRUE(list); | 67 EXPECT_TRUE(list); |
65 return scoped_ptr<base::ListValue>(list); | 68 return std::unique_ptr<base::ListValue>(list); |
66 } | 69 } |
67 | 70 |
68 std::string ExtensionApiUnittest::RunFunctionAndReturnError( | 71 std::string ExtensionApiUnittest::RunFunctionAndReturnError( |
69 UIThreadExtensionFunction* function, const std::string& args) { | 72 UIThreadExtensionFunction* function, const std::string& args) { |
70 function->set_extension(extension()); | 73 function->set_extension(extension()); |
71 return utils::RunFunctionAndReturnError(function, args, browser()); | 74 return utils::RunFunctionAndReturnError(function, args, browser()); |
72 } | 75 } |
73 | 76 |
74 void ExtensionApiUnittest::RunFunction( | 77 void ExtensionApiUnittest::RunFunction( |
75 UIThreadExtensionFunction* function, const std::string& args) { | 78 UIThreadExtensionFunction* function, const std::string& args) { |
76 RunFunctionAndReturnValue(function, args); | 79 RunFunctionAndReturnValue(function, args); |
77 } | 80 } |
78 | 81 |
79 } // namespace extensions | 82 } // namespace extensions |
OLD | NEW |