| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/threading/platform_thread.h" | 5 #include "base/threading/platform_thread.h" |
| 6 #include "content/browser/geolocation/device_data_provider.h" | |
| 7 #include "content/browser/geolocation/wifi_data_provider_common.h" | 6 #include "content/browser/geolocation/wifi_data_provider_common.h" |
| 7 #include "content/browser/geolocation/wifi_data_provider.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 class NullWifiDataListenerInterface | 12 class NullWifiDataListenerInterface |
| 13 : public WifiDataProviderCommon::ListenerInterface { | 13 : public WifiDataProviderCommon::ListenerInterface { |
| 14 public: | 14 public: |
| 15 // ListenerInterface | 15 // ListenerInterface |
| 16 virtual void DeviceDataUpdateAvailable( | 16 virtual void DeviceDataUpdateAvailable(WifiDataProvider* provider) {} |
| 17 DeviceDataProvider<WifiData>* provider) {} | |
| 18 }; | 17 }; |
| 19 | 18 |
| 20 TEST(GeolocationDeviceDataProviderWifiData, CreateDestroy) { | 19 TEST(GeolocationDeviceDataProviderWifiData, CreateDestroy) { |
| 21 // See http://crbug.com/59913 . The main_message_loop is not required to be | 20 // See http://crbug.com/59913 . The main_message_loop is not required to be |
| 22 // run for correct behaviour, but we run it in this test to help smoke out | 21 // run for correct behaviour, but we run it in this test to help smoke out |
| 23 // any race conditions between processing in the main loop and the setup / | 22 // any race conditions between processing in the main loop and the setup / |
| 24 // tear down of the DeviceDataProvider thread. | 23 // tear down of the DeviceDataProvider thread. |
| 25 MessageLoopForUI main_message_loop; | 24 MessageLoopForUI main_message_loop; |
| 26 NullWifiDataListenerInterface listener; | 25 NullWifiDataListenerInterface listener; |
| 27 for (int i = 0; i < 10; i++) { | 26 for (int i = 0; i < 10; i++) { |
| 28 DeviceDataProvider<WifiData>::Register(&listener); | 27 WifiDataProvider::Register(&listener); |
| 29 for (int j = 0; j < 10; j++) { | 28 for (int j = 0; j < 10; j++) { |
| 30 base::PlatformThread::Sleep(base::TimeDelta()); | 29 base::PlatformThread::Sleep(base::TimeDelta()); |
| 31 main_message_loop.RunAllPending(); // See comment above | 30 main_message_loop.RunAllPending(); // See comment above |
| 32 } | 31 } |
| 33 DeviceDataProvider<WifiData>::Unregister(&listener); | 32 WifiDataProvider::Unregister(&listener); |
| 34 for (int j = 0; j < 10; j++) { | 33 for (int j = 0; j < 10; j++) { |
| 35 base::PlatformThread::Sleep(base::TimeDelta()); | 34 base::PlatformThread::Sleep(base::TimeDelta()); |
| 36 main_message_loop.RunAllPending(); // See comment above | 35 main_message_loop.RunAllPending(); // See comment above |
| 37 } | 36 } |
| 38 } | 37 } |
| 39 } | 38 } |
| 40 | 39 |
| 41 } // namespace | 40 } // namespace |
| OLD | NEW |