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

Side by Side Diff: content/browser/gamepad/gamepad_provider_unittest.cc

Issue 8678038: increase read contention count value on gamepad provider unittest (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add crbug and FLAKY_ Created 9 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/process_util.h" 6 #include "base/process_util.h"
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "base/system_monitor/system_monitor.h" 8 #include "base/system_monitor/system_monitor.h"
9 #include "content/browser/gamepad/gamepad_provider.h" 9 #include "content/browser/gamepad/gamepad_provider.h"
10 #include "content/common/gamepad_messages.h" 10 #include "content/common/gamepad_messages.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 scoped_refptr<gamepad::Provider> provider_; 56 scoped_refptr<gamepad::Provider> provider_;
57 }; 57 };
58 58
59 TEST_F(GamepadProviderTest, BasicStartStop) { 59 TEST_F(GamepadProviderTest, BasicStartStop) {
60 gamepad::Provider* provider = CreateProvider(); 60 gamepad::Provider* provider = CreateProvider();
61 provider->Start(); 61 provider->Start();
62 provider->Stop(); 62 provider->Stop();
63 // Just ensure that there's no asserts on startup, shutdown, or destroy. 63 // Just ensure that there's no asserts on startup, shutdown, or destroy.
64 } 64 }
65 65
66 TEST_F(GamepadProviderTest, PollingAccess) { 66 // http://crbug.com/105348
67 TEST_F(GamepadProviderTest, FLAKY_PollingAccess) {
67 using namespace gamepad; 68 using namespace gamepad;
68 69
69 Provider* provider = CreateProvider(); 70 Provider* provider = CreateProvider();
70 provider->Start(); 71 provider->Start();
71 72
72 WebKit::WebGamepads test_data; 73 WebKit::WebGamepads test_data;
73 test_data.length = 1; 74 test_data.length = 1;
74 test_data.items[0].connected = true; 75 test_data.items[0].connected = true;
75 test_data.items[0].timestamp = 0; 76 test_data.items[0].timestamp = 0;
76 test_data.items[0].buttonsLength = 1; 77 test_data.items[0].buttonsLength = 1;
(...skipping 17 matching lines...) Expand all
94 95
95 GamepadHardwareBuffer* hwbuf = static_cast<GamepadHardwareBuffer*>(mem); 96 GamepadHardwareBuffer* hwbuf = static_cast<GamepadHardwareBuffer*>(mem);
96 // See gamepad_hardware_buffer.h for details on the read discipline. 97 // See gamepad_hardware_buffer.h for details on the read discipline.
97 base::subtle::Atomic32 start, end; 98 base::subtle::Atomic32 start, end;
98 WebKit::WebGamepads output; 99 WebKit::WebGamepads output;
99 int contention_count; 100 int contention_count;
100 101
101 // Here we're attempting to test the read discipline during contention. If 102 // Here we're attempting to test the read discipline during contention. If
102 // we fail to read this many times, then the read thread is starving, and we 103 // we fail to read this many times, then the read thread is starving, and we
103 // should fail the test. 104 // should fail the test.
104 for (contention_count = 0; contention_count < 10; ++contention_count) { 105 for (contention_count = 0; contention_count < 1000; ++contention_count) {
105 end = base::subtle::Acquire_Load(&hwbuf->end_marker); 106 end = base::subtle::Acquire_Load(&hwbuf->end_marker);
106 memcpy(&output, &hwbuf->buffer, sizeof(output)); 107 memcpy(&output, &hwbuf->buffer, sizeof(output));
107 start = base::subtle::Acquire_Load(&hwbuf->start_marker); 108 start = base::subtle::Acquire_Load(&hwbuf->start_marker);
108 if (start == end) 109 if (start == end)
109 break; 110 break;
110 base::PlatformThread::YieldCurrentThread(); 111 base::PlatformThread::YieldCurrentThread();
111 } 112 }
112 EXPECT_GT(10, contention_count); 113 EXPECT_GT(1000, contention_count);
113 EXPECT_EQ(1u, output.length); 114 EXPECT_EQ(1u, output.length);
114 EXPECT_EQ(1u, output.items[0].buttonsLength); 115 EXPECT_EQ(1u, output.items[0].buttonsLength);
115 EXPECT_EQ(1.f, output.items[0].buttons[0]); 116 EXPECT_EQ(1.f, output.items[0].buttons[0]);
116 EXPECT_EQ(2u, output.items[0].axesLength); 117 EXPECT_EQ(2u, output.items[0].axesLength);
117 EXPECT_EQ(-1.f, output.items[0].axes[0]); 118 EXPECT_EQ(-1.f, output.items[0].axes[0]);
118 EXPECT_EQ(0.5f, output.items[0].axes[1]); 119 EXPECT_EQ(0.5f, output.items[0].axes[1]);
119 120
120 provider->Stop(); 121 provider->Stop();
121 } 122 }
122 123
123 } // namespace 124 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698