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