blob: 42a678c8d5e699dc9ea6ab2b46d25e9ea2206864 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/threading/platform_thread.h"
#include "content/browser/geolocation/device_data_provider.h"
#include "content/browser/geolocation/wifi_data_provider_common.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
class NullWifiDataListenerInterface
: public WifiDataProviderCommon::ListenerInterface {
public:
// ListenerInterface
virtual void DeviceDataUpdateAvailable(
DeviceDataProvider<WifiData>* provider) OVERRIDE {}
};
TEST(GeolocationDeviceDataProviderWifiData, CreateDestroy) {
// See http://crbug.com/59913 . The main_message_loop is not required to be
// run for correct behaviour, but we run it in this test to help smoke out
// any race conditions between processing in the main loop and the setup /
// tear down of the DeviceDataProvider thread.
base::MessageLoopForUI main_message_loop;
NullWifiDataListenerInterface listener;
for (int i = 0; i < 10; i++) {
DeviceDataProvider<WifiData>::Register(&listener);
for (int j = 0; j < 10; j++) {
base::PlatformThread::Sleep(base::TimeDelta());
main_message_loop.RunUntilIdle(); // See comment above
}
DeviceDataProvider<WifiData>::Unregister(&listener);
for (int j = 0; j < 10; j++) {
base::PlatformThread::Sleep(base::TimeDelta());
main_message_loop.RunUntilIdle(); // See comment above
}
}
}
} // namespace content