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

Unified Diff: base/test/test_support_android.cc

Issue 10408091: Chromium support of running DumpRenderTree as an apk on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes according to comments in Patch Set 3 Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: base/test/test_support_android.cc
diff --git a/base/test/test_stub_android.cc b/base/test/test_support_android.cc
similarity index 81%
rename from base/test/test_stub_android.cc
rename to base/test/test_support_android.cc
index aaf952e232cf5e003baaeedfafe47bfb92594ac9..23aacf1dda394ed3a4096904fc4c01ecd2ff43fe 100644
--- a/base/test/test_stub_android.cc
+++ b/base/test/test_support_android.cc
@@ -68,16 +68,18 @@ class Waitable {
}
base::WaitableEvent waitable_event_;
+
+ DISALLOW_COPY_AND_ASSIGN(Waitable);
};
// The MessagePumpForUI implementation for test purpose.
class MessagePumpForUIStub : public base::MessagePumpForUI {
- void Start(base::MessagePump::Delegate* delegate) {
+ virtual void Start(base::MessagePump::Delegate* delegate) OVERRIDE {
NOTREACHED() << "The Start() method shouldn't be called in test, using"
" Run() method should be used.";
}
- void Run(base::MessagePump::Delegate* delegate) {
+ virtual void Run(base::MessagePump::Delegate* delegate) OVERRIDE {
// The following was based on message_pump_glib.cc, except we're using a
// WaitableEvent since there are no native message loop to use.
RunState state(delegate, g_state ? g_state->run_depth + 1 : 1);
@@ -117,21 +119,26 @@ class MessagePumpForUIStub : public base::MessagePumpForUI {
g_state = previous_state;
}
- void Quit() {
+ virtual void Quit() OVERRIDE {
Waitable::GetInstance()->Quit();
}
- void ScheduleWork() {
+ virtual void ScheduleWork() OVERRIDE {
Waitable::GetInstance()->Signal();
}
- void ScheduleDelayedWork(const base::TimeTicks& delayed_work_time) {
+ virtual void ScheduleDelayedWork(
+ const base::TimeTicks& delayed_work_time) OVERRIDE {
Waitable::GetInstance()->Signal();
}
};
+base::MessagePump* CreateMessagePumpForUIStub() {
+ return new MessagePumpForUIStub();
+};
+
// Provides the test path for DIR_MODULE, DIR_CACHE and DIR_ANDROID_APP_DATA.
-bool PathTestProviderAndroid(int key, FilePath* result) {
+bool GetTestProviderPath(int key, FilePath* result) {
switch (key) {
case base::DIR_MODULE: {
*result = FilePath(kAndroidTestTempDirectory);
@@ -154,21 +161,17 @@ bool PathTestProviderAndroid(int key, FilePath* result) {
}
}
-// The factory method to create a MessagePumpForUI.
-base::MessagePump* CreateMessagePumpForUIStub() {
- return new MessagePumpForUIStub();
+void InitPathProvider(int key) {
+ FilePath path;
+ GetTestProviderPath(key, &path);
+ // If failed to override the key, that means the way has not been registered.
+ if (!PathService::Override(key, path))
+ PathService::RegisterProvider(&GetTestProviderPath, key, key + 1);
}
} // namespace
-void InitAndroidOSPathStub() {
- PathService::Override(base::DIR_MODULE, FilePath(kAndroidTestTempDirectory));
- PathService::Override(base::DIR_CACHE, FilePath(kAndroidTestTempDirectory));
- PathService::Override(base::DIR_ANDROID_APP_DATA,
- FilePath(kAndroidTestTempDirectory));
-}
-
-void InitAndroidTestStub() {
+void InitAndroidTestLogging() {
logging::InitLogging(NULL,
logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
logging::DONT_LOCK_LOG_FILE,
@@ -179,13 +182,20 @@ void InitAndroidTestStub() {
false, // Thread ID
false, // Timestamp
false); // Tick count
+}
- PathService::RegisterProvider(&PathTestProviderAndroid, base::DIR_MODULE,
- base::DIR_MODULE + 1);
- PathService::RegisterProvider(&PathTestProviderAndroid, base::DIR_CACHE,
- base::DIR_CACHE + 1);
- PathService::RegisterProvider(&PathTestProviderAndroid,
- base::DIR_ANDROID_APP_DATA, base::DIR_ANDROID_APP_DATA + 1);
+void InitAndroidTestPaths() {
+ InitPathProvider(base::DIR_MODULE);
+ InitPathProvider(base::DIR_CACHE);
+ InitPathProvider(base::DIR_ANDROID_APP_DATA);
+}
+void InitAndroidTestMessageLoop() {
MessageLoop::InitMessagePumpForUIFactory(&CreateMessagePumpForUIStub);
}
+
+void InitAndroidTest() {
+ InitAndroidTestLogging();
+ InitAndroidTestPaths();
+ InitAndroidTestMessageLoop();
+}

Powered by Google App Engine
This is Rietveld 408576698