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

Side by Side Diff: content/browser/device_sensors/device_inertial_sensor_browsertest.cc

Issue 667943003: Standardize usage of virtual/override/final in content/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/synchronization/waitable_event.h" 6 #include "base/synchronization/waitable_event.h"
7 #include "base/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
8 #include "content/browser/device_sensors/data_fetcher_shared_memory.h" 8 #include "content/browser/device_sensors/data_fetcher_shared_memory.h"
9 #include "content/browser/device_sensors/device_inertial_sensor_service.h" 9 #include "content/browser/device_sensors/device_inertial_sensor_service.h"
10 #include "content/common/device_sensors/device_light_hardware_buffer.h" 10 #include "content/common/device_sensors/device_light_hardware_buffer.h"
(...skipping 16 matching lines...) Expand all
27 class FakeDataFetcher : public DataFetcherSharedMemory { 27 class FakeDataFetcher : public DataFetcherSharedMemory {
28 public: 28 public:
29 FakeDataFetcher() 29 FakeDataFetcher()
30 : started_orientation_(false, false), 30 : started_orientation_(false, false),
31 stopped_orientation_(false, false), 31 stopped_orientation_(false, false),
32 started_motion_(false, false), 32 started_motion_(false, false),
33 stopped_motion_(false, false), 33 stopped_motion_(false, false),
34 started_light_(false, false), 34 started_light_(false, false),
35 stopped_light_(false, false), 35 stopped_light_(false, false),
36 sensor_data_available_(true) {} 36 sensor_data_available_(true) {}
37 virtual ~FakeDataFetcher() { } 37 ~FakeDataFetcher() override {}
38 38
39 virtual bool Start(ConsumerType consumer_type, void* buffer) override { 39 bool Start(ConsumerType consumer_type, void* buffer) override {
40 EXPECT_TRUE(buffer); 40 EXPECT_TRUE(buffer);
41 41
42 switch (consumer_type) { 42 switch (consumer_type) {
43 case CONSUMER_TYPE_MOTION: 43 case CONSUMER_TYPE_MOTION:
44 { 44 {
45 DeviceMotionHardwareBuffer* motion_buffer = 45 DeviceMotionHardwareBuffer* motion_buffer =
46 static_cast<DeviceMotionHardwareBuffer*>(buffer); 46 static_cast<DeviceMotionHardwareBuffer*>(buffer);
47 if (sensor_data_available_) 47 if (sensor_data_available_)
48 UpdateMotion(motion_buffer); 48 UpdateMotion(motion_buffer);
49 SetMotionBufferReady(motion_buffer); 49 SetMotionBufferReady(motion_buffer);
(...skipping 20 matching lines...) Expand all
70 : std::numeric_limits<double>::infinity()); 70 : std::numeric_limits<double>::infinity());
71 started_light_.Signal(); 71 started_light_.Signal();
72 } 72 }
73 break; 73 break;
74 default: 74 default:
75 return false; 75 return false;
76 } 76 }
77 return true; 77 return true;
78 } 78 }
79 79
80 virtual bool Stop(ConsumerType consumer_type) override { 80 bool Stop(ConsumerType consumer_type) override {
81 switch (consumer_type) { 81 switch (consumer_type) {
82 case CONSUMER_TYPE_MOTION: 82 case CONSUMER_TYPE_MOTION:
83 stopped_motion_.Signal(); 83 stopped_motion_.Signal();
84 break; 84 break;
85 case CONSUMER_TYPE_ORIENTATION: 85 case CONSUMER_TYPE_ORIENTATION:
86 stopped_orientation_.Signal(); 86 stopped_orientation_.Signal();
87 break; 87 break;
88 case CONSUMER_TYPE_LIGHT: 88 case CONSUMER_TYPE_LIGHT:
89 stopped_light_.Signal(); 89 stopped_light_.Signal();
90 break; 90 break;
91 default: 91 default:
92 return false; 92 return false;
93 } 93 }
94 return true; 94 return true;
95 } 95 }
96 96
97 virtual void Fetch(unsigned consumer_bitmask) override { 97 void Fetch(unsigned consumer_bitmask) override {
98 FAIL() << "fetch should not be called"; 98 FAIL() << "fetch should not be called";
99 } 99 }
100 100
101 virtual FetcherType GetType() const override { 101 FetcherType GetType() const override { return FETCHER_TYPE_DEFAULT; }
102 return FETCHER_TYPE_DEFAULT;
103 }
104 102
105 void SetSensorDataAvailable(bool available) { 103 void SetSensorDataAvailable(bool available) {
106 sensor_data_available_ = available; 104 sensor_data_available_ = available;
107 } 105 }
108 106
109 void SetMotionBufferReady(DeviceMotionHardwareBuffer* buffer) { 107 void SetMotionBufferReady(DeviceMotionHardwareBuffer* buffer) {
110 buffer->seqlock.WriteBegin(); 108 buffer->seqlock.WriteBegin();
111 buffer->data.allAvailableSensorsAreActive = true; 109 buffer->data.allAvailableSensorsAreActive = true;
112 buffer->seqlock.WriteEnd(); 110 buffer->seqlock.WriteEnd();
113 } 111 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 }; 175 };
178 176
179 177
180 class DeviceInertialSensorBrowserTest : public ContentBrowserTest { 178 class DeviceInertialSensorBrowserTest : public ContentBrowserTest {
181 public: 179 public:
182 DeviceInertialSensorBrowserTest() 180 DeviceInertialSensorBrowserTest()
183 : fetcher_(NULL), 181 : fetcher_(NULL),
184 io_loop_finished_event_(false, false) { 182 io_loop_finished_event_(false, false) {
185 } 183 }
186 184
187 virtual void SetUpOnMainThread() override { 185 void SetUpOnMainThread() override {
188 BrowserThread::PostTask( 186 BrowserThread::PostTask(
189 BrowserThread::IO, FROM_HERE, 187 BrowserThread::IO, FROM_HERE,
190 base::Bind(&DeviceInertialSensorBrowserTest::SetUpOnIOThread, this)); 188 base::Bind(&DeviceInertialSensorBrowserTest::SetUpOnIOThread, this));
191 io_loop_finished_event_.Wait(); 189 io_loop_finished_event_.Wait();
192 } 190 }
193 191
194 void SetUpOnIOThread() { 192 void SetUpOnIOThread() {
195 fetcher_ = new FakeDataFetcher(); 193 fetcher_ = new FakeDataFetcher();
196 DeviceInertialSensorService::GetInstance()-> 194 DeviceInertialSensorService::GetInstance()->
197 SetDataFetcherForTesting(fetcher_); 195 SetDataFetcherForTesting(fetcher_);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 349
352 fetcher_->started_motion_.Wait(); 350 fetcher_->started_motion_.Wait();
353 fetcher_->stopped_motion_.Wait(); 351 fetcher_->stopped_motion_.Wait();
354 same_tab_observer.Wait(); 352 same_tab_observer.Wait();
355 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); 353 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref());
356 } 354 }
357 355
358 } // namespace 356 } // namespace
359 357
360 } // namespace content 358 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698