OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <queue> | 5 #include <queue> |
6 | 6 |
7 #include "base/lock.h" | 7 #include "base/lock.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/task.h" |
9 #include "chrome/browser/device_orientation/data_fetcher.h" | 10 #include "chrome/browser/device_orientation/data_fetcher.h" |
10 #include "chrome/browser/device_orientation/orientation.h" | 11 #include "chrome/browser/device_orientation/orientation.h" |
11 #include "chrome/browser/device_orientation/provider.h" | 12 #include "chrome/browser/device_orientation/provider.h" |
12 #include "chrome/browser/device_orientation/provider_impl.h" | 13 #include "chrome/browser/device_orientation/provider_impl.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace device_orientation { | 16 namespace device_orientation { |
16 namespace { | 17 namespace { |
17 | 18 |
18 // Class for checking expectations on orientation updates from the Provider. | 19 // Class for checking expectations on orientation updates from the Provider. |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( | 304 scoped_ptr<UpdateChecker> checker_a(new UpdateChecker( |
304 &pending_expectations_)); | 305 &pending_expectations_)); |
305 scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( | 306 scoped_ptr<UpdateChecker> checker_b(new UpdateChecker( |
306 &pending_expectations_)); | 307 &pending_expectations_)); |
307 | 308 |
308 checker_a->AddExpectation(kTestOrientation); | 309 checker_a->AddExpectation(kTestOrientation); |
309 orientation_factory->SetOrientation(kTestOrientation); | 310 orientation_factory->SetOrientation(kTestOrientation); |
310 provider_->AddObserver(checker_a.get()); | 311 provider_->AddObserver(checker_a.get()); |
311 MessageLoop::current()->Run(); | 312 MessageLoop::current()->Run(); |
312 | 313 |
313 provider_->RemoveObserver(checker_a.get()); // This stops the Provider. | 314 provider_->RemoveObserver(checker_a.get()); // This stops the Provider. |
314 | 315 |
315 checker_b->AddExpectation(kTestOrientation2); | 316 checker_b->AddExpectation(kTestOrientation2); |
316 orientation_factory->SetOrientation(kTestOrientation2); | 317 orientation_factory->SetOrientation(kTestOrientation2); |
317 provider_->AddObserver(checker_b.get()); | 318 provider_->AddObserver(checker_b.get()); |
318 MessageLoop::current()->Run(); | 319 MessageLoop::current()->Run(); |
319 | 320 |
320 provider_->RemoveObserver(checker_b.get()); | 321 provider_->RemoveObserver(checker_b.get()); |
321 } | 322 } |
322 | 323 |
323 TEST_F(DeviceOrientationProviderTest, SignificantlyDifferent) { | 324 TEST_F(DeviceOrientationProviderTest, SignificantlyDifferent) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 checker_b->AddExpectation(third_orientation); | 364 checker_b->AddExpectation(third_orientation); |
364 MessageLoop::current()->Run(); | 365 MessageLoop::current()->Run(); |
365 | 366 |
366 provider_->RemoveObserver(checker_a.get()); | 367 provider_->RemoveObserver(checker_a.get()); |
367 provider_->RemoveObserver(checker_b.get()); | 368 provider_->RemoveObserver(checker_b.get()); |
368 } | 369 } |
369 | 370 |
370 } // namespace | 371 } // namespace |
371 | 372 |
372 } // namespace device_orientation | 373 } // namespace device_orientation |
OLD | NEW |