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

Side by Side Diff: third_party/WebKit/Source/platform/testing/UnitTestHelpers.cpp

Issue 1774123006: Implement link selection on alt+mouse drag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "platform/testing/UnitTestHelpers.h" 26 #include "platform/testing/UnitTestHelpers.h"
27 27
28 #include "base/files/file_path.h" 28 #include "base/files/file_path.h"
29 #include "base/files/file_util.h" 29 #include "base/files/file_util.h"
30 #include "base/message_loop/message_loop.h" 30 #include "base/message_loop/message_loop.h"
31 #include "base/path_service.h" 31 #include "base/path_service.h"
32 #include "platform/SharedBuffer.h" 32 #include "platform/SharedBuffer.h"
33 #include "platform/Timer.h"
33 #include "public/platform/FilePathConversion.h" 34 #include "public/platform/FilePathConversion.h"
34 #include "public/platform/Platform.h" 35 #include "public/platform/Platform.h"
35 #include "public/platform/WebString.h" 36 #include "public/platform/WebString.h"
36 #include "public/platform/WebTaskRunner.h" 37 #include "public/platform/WebTaskRunner.h"
37 #include "public/platform/WebThread.h" 38 #include "public/platform/WebThread.h"
38 #include "public/platform/WebTraceLocation.h" 39 #include "public/platform/WebTraceLocation.h"
39 #include "public/platform/WebUnitTestSupport.h" 40 #include "public/platform/WebUnitTestSupport.h"
40 #include "wtf/text/StringUTF8Adaptor.h" 41 #include "wtf/text/StringUTF8Adaptor.h"
41 42
42 namespace blink { 43 namespace blink {
43 namespace testing { 44 namespace testing {
44 45
45 void runPendingTasks() 46 void runPendingTasks()
46 { 47 {
47 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO M_HERE, bind(&exitRunLoop)); 48 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK_FRO M_HERE, bind(&exitRunLoop));
48 enterRunLoop(); 49 enterRunLoop();
49 } 50 }
50 51
52 struct QuitTask {
53 void timerFired(Timer<QuitTask>*)
54 {
55 // We cannot just exit loop here, because we may be halfway through the task queue.
56 Platform::current()->currentThread()->getWebTaskRunner()->postTask(BLINK _FROM_HERE, bind(&exitRunLoop));
57 }
58 };
59
60 void waitForDeferredTasks(double interval)
61 {
62 // Pending tasks include Timers that have been scheduled.
63 Timer<QuitTask> quitOnTimeout(new QuitTask, &QuitTask::timerFired);
64 quitOnTimeout.startOneShot(interval, BLINK_FROM_HERE);
65 testing::enterRunLoop();
66 }
67
51 String blinkRootDir() 68 String blinkRootDir()
52 { 69 {
53 base::FilePath path; 70 base::FilePath path;
54 base::PathService::Get(base::DIR_SOURCE_ROOT, &path); 71 base::PathService::Get(base::DIR_SOURCE_ROOT, &path);
55 path = path.Append(FILE_PATH_LITERAL("third_party/WebKit")); 72 path = path.Append(FILE_PATH_LITERAL("third_party/WebKit"));
56 path = base::MakeAbsoluteFilePath(path); 73 path = base::MakeAbsoluteFilePath(path);
57 return String::fromUTF8(path.MaybeAsASCII().c_str()); 74 return String::fromUTF8(path.MaybeAsASCII().c_str());
58 } 75 }
59 76
60 PassRefPtr<SharedBuffer> readFromFile(const String& path) 77 PassRefPtr<SharedBuffer> readFromFile(const String& path)
(...skipping 14 matching lines...) Expand all
75 base::MessageLoop::current()->QuitWhenIdle(); 92 base::MessageLoop::current()->QuitWhenIdle();
76 } 93 }
77 94
78 void yieldCurrentThread() 95 void yieldCurrentThread()
79 { 96 {
80 base::PlatformThread::YieldCurrentThread(); 97 base::PlatformThread::YieldCurrentThread();
81 } 98 }
82 99
83 } // namespace testing 100 } // namespace testing
84 } // namespace blink 101 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698