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