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

Side by Side Diff: Source/web/tests/SpinLockTest.cpp

Issue 1174283002: Fix unit test style in Source/web/. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove static Created 5 years, 6 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
« no previous file with comments | « Source/web/tests/ScrollingCoordinatorTest.cpp ('k') | Source/web/tests/TextFinderTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 22 matching lines...) Expand all
33 33
34 #include "platform/Task.h" 34 #include "platform/Task.h"
35 #include "platform/ThreadSafeFunctional.h" 35 #include "platform/ThreadSafeFunctional.h"
36 #include "public/platform/Platform.h" 36 #include "public/platform/Platform.h"
37 #include "public/platform/WebThread.h" 37 #include "public/platform/WebThread.h"
38 #include "public/platform/WebTraceLocation.h" 38 #include "public/platform/WebTraceLocation.h"
39 #include "wtf/OwnPtr.h" 39 #include "wtf/OwnPtr.h"
40 #include "wtf/PassOwnPtr.h" 40 #include "wtf/PassOwnPtr.h"
41 #include <gtest/gtest.h> 41 #include <gtest/gtest.h>
42 42
43 namespace { 43 namespace blink {
44
45 using namespace blink;
46 44
47 static const size_t bufferSize = 16; 45 static const size_t bufferSize = 16;
48 46
49 static int lock = 0; 47 static int lock = 0;
50 48
51 static void fillBuffer(volatile char* buffer, char fillPattern) 49 static void fillBuffer(volatile char* buffer, char fillPattern)
52 { 50 {
53 for (size_t i = 0; i < bufferSize; ++i) 51 for (size_t i = 0; i < bufferSize; ++i)
54 buffer[i] = fillPattern; 52 buffer[i] = fillPattern;
55 } 53 }
(...skipping 14 matching lines...) Expand all
70 68
71 static void threadMain(volatile char* buffer) 69 static void threadMain(volatile char* buffer)
72 { 70 {
73 for (int i = 0; i < 500000; ++i) { 71 for (int i = 0; i < 500000; ++i) {
74 spinLockLock(&lock); 72 spinLockLock(&lock);
75 changeAndCheckBuffer(buffer); 73 changeAndCheckBuffer(buffer);
76 spinLockUnlock(&lock); 74 spinLockUnlock(&lock);
77 } 75 }
78 } 76 }
79 77
80 TEST(WTF_SpinLock, Torture) 78 TEST(SpinLockTest, Torture)
81 { 79 {
82 char sharedBuffer[bufferSize]; 80 char sharedBuffer[bufferSize];
83 81
84 OwnPtr<WebThread> thread1 = adoptPtr(Platform::current()->createThread("thre ad1")); 82 OwnPtr<WebThread> thread1 = adoptPtr(Platform::current()->createThread("thre ad1"));
85 OwnPtr<WebThread> thread2 = adoptPtr(Platform::current()->createThread("thre ad2")); 83 OwnPtr<WebThread> thread2 = adoptPtr(Platform::current()->createThread("thre ad2"));
86 84
87 thread1->postTask(FROM_HERE, new Task(threadSafeBind(&threadMain, AllowCross ThreadAccess(static_cast<char*>(sharedBuffer))))); 85 thread1->postTask(FROM_HERE, new Task(threadSafeBind(&threadMain, AllowCross ThreadAccess(static_cast<char*>(sharedBuffer)))));
88 thread2->postTask(FROM_HERE, new Task(threadSafeBind(&threadMain, AllowCross ThreadAccess(static_cast<char*>(sharedBuffer))))); 86 thread2->postTask(FROM_HERE, new Task(threadSafeBind(&threadMain, AllowCross ThreadAccess(static_cast<char*>(sharedBuffer)))));
89 87
90 thread1.clear(); 88 thread1.clear();
91 thread2.clear(); 89 thread2.clear();
92 } 90 }
93 91
94 } // namespace 92 } // namespace blink
OLDNEW
« no previous file with comments | « Source/web/tests/ScrollingCoordinatorTest.cpp ('k') | Source/web/tests/TextFinderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698