Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Unified Diff: content/browser/geolocation/geolocation_provider_unittest.cc

Issue 10103029: Add device location reporting (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed. Also added lots of includes to IWYU. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/geolocation/geolocation_provider_unittest.cc
diff --git a/content/browser/geolocation/geolocation_provider_unittest.cc b/content/browser/geolocation/geolocation_provider_unittest.cc
index 1b131e93d59a11dfc42754b68cebfca15f412196..b087fa8cb930c99e1a3d8077578e8965cd7071ba 100644
--- a/content/browser/geolocation/geolocation_provider_unittest.cc
+++ b/content/browser/geolocation/geolocation_provider_unittest.cc
@@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/memory/singleton.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/message_loop.h"
#include "base/synchronization/waitable_event.h"
#include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h"
#include "content/browser/geolocation/fake_access_token_store.h"
#include "content/browser/geolocation/geolocation_provider.h"
#include "content/browser/geolocation/location_arbitrator.h"
#include "content/browser/geolocation/mock_location_provider.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/test/test_browser_thread.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -22,20 +25,25 @@ using testing::InvokeWithoutArgs;
namespace {
+// A GeolocationProvider that can be constructed and destructed for testing.
+class NonSingletonGeolocationProvider : public GeolocationProvider {
+ public:
+ NonSingletonGeolocationProvider() : GeolocationProvider() { }
+
+ virtual ~NonSingletonGeolocationProvider() {}
+};
+
class GeolocationProviderTest : public testing::Test {
protected:
GeolocationProviderTest()
- : provider_(new GeolocationProvider),
+ : io_thread_(content::BrowserThread::IO, &message_loop_),
+ provider_(new NonSingletonGeolocationProvider),
dependency_factory_(
new GeolocationArbitratorDependencyFactoryWithLocationProvider(
&NewAutoSuccessMockNetworkLocationProvider))
{
}
- ~GeolocationProviderTest() {
- DefaultSingletonTraits<GeolocationProvider>::Delete(provider_);
- }
-
// testing::Test
virtual void SetUp() {
GeolocationArbitrator::SetDependencyFactoryForTest(
@@ -48,12 +56,11 @@ class GeolocationProviderTest : public testing::Test {
GeolocationArbitrator::SetDependencyFactoryForTest(NULL);
}
- // Message loop for main thread, as provider depends on it existing.
+ // The GeolocationProvider expects to be instantiated on the IO thread.
MessageLoop message_loop_;
+ content::TestBrowserThread io_thread_;
- // Object under tests. Owned, but not a scoped_ptr due to specialized
- // destruction protocol.
- GeolocationProvider* provider_;
+ scoped_ptr<NonSingletonGeolocationProvider> provider_;
scoped_refptr<GeolocationArbitratorDependencyFactory> dependency_factory_;
};

Powered by Google App Engine
This is Rietveld 408576698