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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "chrome/test/base/browser_with_test_window_test.h" | 12 #include "chrome/test/base/browser_with_test_window_test.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class Value; | 15 class Value; |
16 class DictionaryValue; | 16 class DictionaryValue; |
17 class ListValue; | 17 class ListValue; |
18 } | 18 } |
19 | 19 |
20 class UIThreadExtensionFunction; | 20 class UIThreadExtensionFunction; |
21 | 21 |
(...skipping 24 matching lines...) Expand all Loading... |
46 | 46 |
47 protected: | 47 protected: |
48 // SetUp creates and loads an empty, unpacked Extension. | 48 // SetUp creates and loads an empty, unpacked Extension. |
49 void SetUp() override; | 49 void SetUp() override; |
50 | 50 |
51 // Various ways of running an API function. These methods take ownership of | 51 // Various ways of running an API function. These methods take ownership of |
52 // |function|. |args| should be in JSON format, wrapped in a list. | 52 // |function|. |args| should be in JSON format, wrapped in a list. |
53 // See also the RunFunction* methods in extension_function_test_utils.h. | 53 // See also the RunFunction* methods in extension_function_test_utils.h. |
54 | 54 |
55 // Return the function result as a base::Value. | 55 // Return the function result as a base::Value. |
56 scoped_ptr<base::Value> RunFunctionAndReturnValue( | 56 std::unique_ptr<base::Value> RunFunctionAndReturnValue( |
57 UIThreadExtensionFunction* function, const std::string& args); | 57 UIThreadExtensionFunction* function, |
| 58 const std::string& args); |
58 | 59 |
59 // Return the function result as a base::DictionaryValue, or NULL. | 60 // Return the function result as a base::DictionaryValue, or NULL. |
60 // This will EXPECT-fail if the result is not a DictionaryValue. | 61 // This will EXPECT-fail if the result is not a DictionaryValue. |
61 scoped_ptr<base::DictionaryValue> RunFunctionAndReturnDictionary( | 62 std::unique_ptr<base::DictionaryValue> RunFunctionAndReturnDictionary( |
62 UIThreadExtensionFunction* function, const std::string& args); | 63 UIThreadExtensionFunction* function, |
| 64 const std::string& args); |
63 | 65 |
64 // Return the function result as a base::ListValue, or NULL. | 66 // Return the function result as a base::ListValue, or NULL. |
65 // This will EXPECT-fail if the result is not a ListValue. | 67 // This will EXPECT-fail if the result is not a ListValue. |
66 scoped_ptr<base::ListValue> RunFunctionAndReturnList( | 68 std::unique_ptr<base::ListValue> RunFunctionAndReturnList( |
67 UIThreadExtensionFunction* function, const std::string& args); | 69 UIThreadExtensionFunction* function, |
| 70 const std::string& args); |
68 | 71 |
69 // Return an error thrown from the function, if one exists. | 72 // Return an error thrown from the function, if one exists. |
70 // This will EXPECT-fail if any result is returned from the function. | 73 // This will EXPECT-fail if any result is returned from the function. |
71 std::string RunFunctionAndReturnError( | 74 std::string RunFunctionAndReturnError( |
72 UIThreadExtensionFunction* function, const std::string& args); | 75 UIThreadExtensionFunction* function, const std::string& args); |
73 | 76 |
74 // Run the function and ignore any result. | 77 // Run the function and ignore any result. |
75 void RunFunction( | 78 void RunFunction( |
76 UIThreadExtensionFunction* function, const std::string& args); | 79 UIThreadExtensionFunction* function, const std::string& args); |
77 | 80 |
78 private: | 81 private: |
79 // The Extension used when running API function calls. | 82 // The Extension used when running API function calls. |
80 scoped_refptr<Extension> extension_; | 83 scoped_refptr<Extension> extension_; |
81 }; | 84 }; |
82 | 85 |
83 } // namespace extensions | 86 } // namespace extensions |
84 | 87 |
85 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ | 88 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_API_UNITTEST_H_ |
OLD | NEW |