OLD | NEW |
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 <stdarg.h> | 5 #include <stdarg.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "base/android/path_utils.h" | 8 #include "base/android/path_utils.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 132 |
133 protected: | 133 protected: |
134 virtual ~MessagePumpForUIStub() {} | 134 virtual ~MessagePumpForUIStub() {} |
135 }; | 135 }; |
136 | 136 |
137 base::MessagePump* CreateMessagePumpForUIStub() { | 137 base::MessagePump* CreateMessagePumpForUIStub() { |
138 return new MessagePumpForUIStub(); | 138 return new MessagePumpForUIStub(); |
139 }; | 139 }; |
140 | 140 |
141 // Provides the test path for DIR_MODULE and DIR_ANDROID_APP_DATA. | 141 // Provides the test path for DIR_MODULE and DIR_ANDROID_APP_DATA. |
142 bool GetTestProviderPath(int key, FilePath* result) { | 142 bool GetTestProviderPath(int key, base::FilePath* result) { |
143 switch (key) { | 143 switch (key) { |
144 case base::DIR_MODULE: { | 144 case base::DIR_MODULE: { |
145 return base::android::GetExternalStorageDirectory(result); | 145 return base::android::GetExternalStorageDirectory(result); |
146 } | 146 } |
147 case base::DIR_ANDROID_APP_DATA: { | 147 case base::DIR_ANDROID_APP_DATA: { |
148 // For tests, app data is put in external storage. | 148 // For tests, app data is put in external storage. |
149 return base::android::GetExternalStorageDirectory(result); | 149 return base::android::GetExternalStorageDirectory(result); |
150 } | 150 } |
151 default: | 151 default: |
152 return false; | 152 return false; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void InitPathProvider(int key) { | 156 void InitPathProvider(int key) { |
157 FilePath path; | 157 base::FilePath path; |
158 // If failed to override the key, that means the way has not been registered. | 158 // If failed to override the key, that means the way has not been registered. |
159 if (GetTestProviderPath(key, &path) && !PathService::Override(key, path)) | 159 if (GetTestProviderPath(key, &path) && !PathService::Override(key, path)) |
160 PathService::RegisterProvider(&GetTestProviderPath, key, key + 1); | 160 PathService::RegisterProvider(&GetTestProviderPath, key, key + 1); |
161 } | 161 } |
162 | 162 |
163 } // namespace | 163 } // namespace |
164 | 164 |
165 namespace base { | 165 namespace base { |
166 | 166 |
167 void InitAndroidTestLogging() { | 167 void InitAndroidTestLogging() { |
(...skipping 18 matching lines...) Expand all Loading... |
186 if (!MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub)) | 186 if (!MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub)) |
187 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; | 187 LOG(INFO) << "MessagePumpForUIFactory already set, unable to override."; |
188 } | 188 } |
189 | 189 |
190 void InitAndroidTest() { | 190 void InitAndroidTest() { |
191 InitAndroidTestLogging(); | 191 InitAndroidTestLogging(); |
192 InitAndroidTestPaths(); | 192 InitAndroidTestPaths(); |
193 InitAndroidTestMessageLoop(); | 193 InitAndroidTestMessageLoop(); |
194 } | 194 } |
195 } // namespace base | 195 } // namespace base |
OLD | NEW |