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

Side by Side Diff: chrome/browser/chromeos/extensions/power/power_api_browsertest.cc

Issue 12089062: Move API functions registrations out of ExtensionFunctionRegistry. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "chrome/browser/chromeos/extensions/power/power_api.h" 6 #include "chrome/browser/chromeos/extensions/power/power_api.h"
7 #include "chrome/browser/extensions/extension_function_test_utils.h" 7 #include "chrome/browser/extensions/extension_function_test_utils.h"
8 #include "chrome/common/extensions/extension_test_util.h" 8 #include "chrome/common/extensions/extension_test_util.h"
9 #include "chrome/common/extensions/manifest.h" 9 #include "chrome/common/extensions/manifest.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
12 #include "chromeos/dbus/mock_dbus_thread_manager.h" 12 #include "chromeos/dbus/mock_dbus_thread_manager.h"
13 #include "chromeos/dbus/mock_power_manager_client.h" 13 #include "chromeos/dbus/mock_power_manager_client.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 using ::testing::_; 16 using ::testing::_;
17 using ::testing::Return; 17 using ::testing::Return;
18 18
19 namespace extensions { 19 namespace extensions {
20 namespace power {
21 20
22 class PowerApiTest : public InProcessBrowserTest { 21 class PowerApiTest : public InProcessBrowserTest {
23 public: 22 public:
24 PowerApiTest() {} 23 PowerApiTest() {}
25 virtual ~PowerApiTest() {} 24 virtual ~PowerApiTest() {}
26 25
27 virtual void SetUp() OVERRIDE { 26 virtual void SetUp() OVERRIDE {
28 chromeos::MockDBusThreadManager* mock_dbus_thread_manager = 27 chromeos::MockDBusThreadManager* mock_dbus_thread_manager =
29 new chromeos::MockDBusThreadManager; 28 new chromeos::MockDBusThreadManager;
30 29
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 76 }
78 77
79 // Adds an expectation that CancelPowerStateOverrides() will be called once to 78 // Adds an expectation that CancelPowerStateOverrides() will be called once to
80 // cancel an override previously created via 79 // cancel an override previously created via
81 // AddRequestPowerStateOverridesExpectation(). 80 // AddRequestPowerStateOverridesExpectation().
82 void AddCancelPowerStateOverridesExpectation() { 81 void AddCancelPowerStateOverridesExpectation() {
83 EXPECT_CALL(*power_client_, CancelPowerStateOverrides(kRequestId)).Times(1); 82 EXPECT_CALL(*power_client_, CancelPowerStateOverrides(kRequestId)).Times(1);
84 } 83 }
85 84
86 void RequestKeepAwake(scoped_refptr<Extension> extension) { 85 void RequestKeepAwake(scoped_refptr<Extension> extension) {
87 scoped_refptr<RequestKeepAwakeFunction> function( 86 scoped_refptr<PowerRequestKeepAwakeFunction> function(
88 new RequestKeepAwakeFunction); 87 new PowerRequestKeepAwakeFunction);
89 RunFunctionAndExpectPass(function.get(), extension); 88 RunFunctionAndExpectPass(function.get(), extension);
90 } 89 }
91 90
92 void ReleaseKeepAwake(scoped_refptr<Extension> extension) { 91 void ReleaseKeepAwake(scoped_refptr<Extension> extension) {
93 scoped_refptr<ReleaseKeepAwakeFunction> function( 92 scoped_refptr<PowerReleaseKeepAwakeFunction> function(
94 new ReleaseKeepAwakeFunction); 93 new PowerReleaseKeepAwakeFunction);
95 RunFunctionAndExpectPass(function.get(), extension); 94 RunFunctionAndExpectPass(function.get(), extension);
96 } 95 }
97 96
98 chromeos::MockPowerManagerClient* power_client_; 97 chromeos::MockPowerManagerClient* power_client_;
99 98
100 chromeos::PowerStateRequestIdCallback request_id_callback_; 99 chromeos::PowerStateRequestIdCallback request_id_callback_;
101 100
102 private: 101 private:
103 DISALLOW_COPY_AND_ASSIGN(PowerApiTest); 102 DISALLOW_COPY_AND_ASSIGN(PowerApiTest);
104 }; 103 };
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 request_id_callback_.Run(kRequestId); 151 request_id_callback_.Run(kRequestId);
153 152
154 AddCancelPowerStateOverridesExpectation(); 153 AddCancelPowerStateOverridesExpectation();
155 ReleaseKeepAwake(extension3); 154 ReleaseKeepAwake(extension3);
156 ReleaseKeepAwake(extension1); 155 ReleaseKeepAwake(extension1);
157 ReleaseKeepAwake(extension2); 156 ReleaseKeepAwake(extension2);
158 } 157 }
159 158
160 // TODO(rkc): Add another test to verify a Request->Release->Request scenario. 159 // TODO(rkc): Add another test to verify a Request->Release->Request scenario.
161 160
162 } // namespace power
163 } // namespace extensions 161 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698