summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 17:10:26 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-24 17:10:26 +0000
commitf7f9819d66ea030ff43ca813ee87828cfce1fa29 (patch)
tree1b5c0d080c2b6066a1dff0f367d6efc02f7635bf /content
parentb081d6c2216f187cd27b96f24489f8fbb038c8f1 (diff)
downloadchromium_src-f7f9819d66ea030ff43ca813ee87828cfce1fa29.zip
chromium_src-f7f9819d66ea030ff43ca813ee87828cfce1fa29.tar.gz
chromium_src-f7f9819d66ea030ff43ca813ee87828cfce1fa29.tar.bz2
Get rid of a bunch of geolocation includes in chrome tests. I've created a simple mock class that tests which use geolocation can use to wrap this complexity.
BUG=98716 Review URL: https://chromiumcodereview.appspot.com/9285011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/content_browser.gypi1
-rw-r--r--content/content_tests.gypi2
-rw-r--r--content/public/browser/access_token_store.cc15
-rw-r--r--content/public/browser/access_token_store.h9
-rw-r--r--content/test/mock_geolocation.cc39
-rw-r--r--content/test/mock_geolocation.h40
6 files changed, 84 insertions, 22 deletions
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index ce38ebc..e4d73c3 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -25,7 +25,6 @@
'<(INTERMEDIATE_DIR)',
],
'sources': [
- 'public/browser/access_token_store.cc',
'public/browser/access_token_store.h',
'public/browser/browser_child_process_host.h',
'public/browser/browser_child_process_host_delegate.cc',
diff --git a/content/content_tests.gypi b/content/content_tests.gypi
index 2e3e4b5..8208507 100644
--- a/content/content_tests.gypi
+++ b/content/content_tests.gypi
@@ -86,6 +86,8 @@
'test/content_test_suite.cc',
'test/content_test_suite.h',
'test/js_injection_ready_observer.h',
+ 'test/mock_geolocation.cc',
+ 'test/mock_geolocation.h',
'test/mock_keyboard.cc',
'test/mock_keyboard.h',
'test/mock_keyboard_driver_win.cc',
diff --git a/content/public/browser/access_token_store.cc b/content/public/browser/access_token_store.cc
deleted file mode 100644
index ba563f4..0000000
--- a/content/public/browser/access_token_store.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) 2011 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 "content/public/browser/access_token_store.h"
-
-namespace content {
-
-AccessTokenStore::AccessTokenStore() {
-}
-
-AccessTokenStore::~AccessTokenStore() {
-}
-
-} // namespace content
diff --git a/content/public/browser/access_token_store.h b/content/public/browser/access_token_store.h
index 1dfaabf..dbfd6e0 100644
--- a/content/public/browser/access_token_store.h
+++ b/content/public/browser/access_token_store.h
@@ -44,7 +44,7 @@ class AccessTokenStore : public base::RefCountedThreadSafe<AccessTokenStore> {
// in Chrome the call to obtain this must also be performed on the UI thread
// so it is efficient to piggyback it onto this request.
// Takes ownership of |callback|.
- CONTENT_EXPORT virtual void LoadAccessTokens(
+ virtual void LoadAccessTokens(
const LoadAccessTokensCallbackType& callback) = 0;
virtual void SaveAccessToken(
@@ -52,11 +52,8 @@ class AccessTokenStore : public base::RefCountedThreadSafe<AccessTokenStore> {
protected:
friend class base::RefCountedThreadSafe<AccessTokenStore>;
- CONTENT_EXPORT AccessTokenStore();
- CONTENT_EXPORT virtual ~AccessTokenStore();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(AccessTokenStore);
+ CONTENT_EXPORT AccessTokenStore() {}
+ CONTENT_EXPORT virtual ~AccessTokenStore() {}
};
} // namespace content
diff --git a/content/test/mock_geolocation.cc b/content/test/mock_geolocation.cc
new file mode 100644
index 0000000..54085b1
--- /dev/null
+++ b/content/test/mock_geolocation.cc
@@ -0,0 +1,39 @@
+// 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 "content/test/mock_geolocation.h"
+
+#include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h"
+#include "content/browser/geolocation/location_arbitrator.h"
+#include "content/browser/geolocation/mock_location_provider.h"
+
+namespace content {
+
+MockGeolocation::MockGeolocation() {
+ dependency_factory_ =
+ new GeolocationArbitratorDependencyFactoryWithLocationProvider(
+ &NewAutoSuccessMockLocationProvider);
+}
+
+MockGeolocation::~MockGeolocation() {
+}
+
+void MockGeolocation::Setup() {
+ GeolocationArbitrator::SetDependencyFactoryForTest(
+ dependency_factory_.get());
+}
+
+void MockGeolocation::TearDown() {
+ GeolocationArbitrator::SetDependencyFactoryForTest(NULL);
+}
+
+Geoposition MockGeolocation::GetCurrentPosition() const {
+ return MockLocationProvider::instance_->position_;
+}
+
+void MockGeolocation::SetCurrentPosition(const Geoposition& position) {
+ MockLocationProvider::instance_->HandlePositionChanged(position);
+}
+
+} // namespace content
diff --git a/content/test/mock_geolocation.h b/content/test/mock_geolocation.h
new file mode 100644
index 0000000..309e890
--- /dev/null
+++ b/content/test/mock_geolocation.h
@@ -0,0 +1,40 @@
+// 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.
+
+#ifndef CONTENT_TEST_MOCK_GEOLOCATION_H_
+#define CONTENT_TEST_MOCK_GEOLOCATION_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+
+class GeolocationArbitratorDependencyFactory;
+struct Geoposition;
+
+namespace content {
+
+// Creates a mock location provider that gives a valid location.
+class MockGeolocation {
+ public:
+ MockGeolocation();
+ ~MockGeolocation();
+
+ // Call this in the test's Setup function.
+ void Setup();
+
+ // Call this in the test's TearDown function.
+ void TearDown();
+
+ Geoposition GetCurrentPosition() const;
+ void SetCurrentPosition(const Geoposition& position);
+
+ private:
+ scoped_refptr<GeolocationArbitratorDependencyFactory> dependency_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(MockGeolocation);
+};
+
+} // namespace content
+
+#endif // CONTENT_TEST_MOCK_GEOLOCATION_H_