Commit 5ba9c9ae authored by jknotten@chromium.org's avatar jknotten@chromium.org

Put geolocation unit and browser test code in anonymous namespaces.

Avoid overlapping class definitions (e.g. MessageLoopQuitListener).

BUG=None
TEST=unit_tests,browser_tests

Review URL: http://codereview.chromium.org/6341013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72793 0039d316-1c4b-4281-b951-d872f2087c98
parent b20c4619
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
#include "chrome/test/ui_test_utils.h" #include "chrome/test/ui_test_utils.h"
namespace { namespace {
// The token store factory implementation expects to be used from any well-known // The token store factory implementation expects to be used from any well-known
// chrome thread other than UI. We could use any arbitrary thread; IO is // chrome thread other than UI. We could use any arbitrary thread; IO is
// a good choice as this is the expected usage. // a good choice as this is the expected usage.
const BrowserThread::ID kExpectedClientThreadId = BrowserThread::IO; const BrowserThread::ID kExpectedClientThreadId = BrowserThread::IO;
const char* kRefServerUrl1 = "https://test.domain.example/foo?id=bar.bar"; const char* kRefServerUrl1 = "https://test.domain.example/foo?id=bar.bar";
const char* kRefServerUrl2 = "http://another.domain.example/foo?id=bar.bar#2"; const char* kRefServerUrl2 = "http://another.domain.example/foo?id=bar.bar#2";
} // namespace
class GeolocationAccessTokenStoreTest class GeolocationAccessTokenStoreTest
: public InProcessBrowserTest { : public InProcessBrowserTest {
...@@ -149,3 +149,5 @@ IN_PROC_BROWSER_TEST_F(GeolocationAccessTokenStoreTest, CancelRequest) { ...@@ -149,3 +149,5 @@ IN_PROC_BROWSER_TEST_F(GeolocationAccessTokenStoreTest, CancelRequest) {
RunCancelTestInClientTread)); RunCancelTestInClientTread));
ui_test_utils::RunMessageLoop(); ui_test_utils::RunMessageLoop();
} }
} // namespace
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace { namespace {
class NullWifiDataListenerInterface class NullWifiDataListenerInterface
: public WifiDataProviderCommon::ListenerInterface { : public WifiDataProviderCommon::ListenerInterface {
public: public:
...@@ -16,7 +17,6 @@ class NullWifiDataListenerInterface ...@@ -16,7 +17,6 @@ class NullWifiDataListenerInterface
virtual void DeviceDataUpdateAvailable( virtual void DeviceDataUpdateAvailable(
DeviceDataProvider<WifiData>* provider) {} DeviceDataProvider<WifiData>* provider) {}
}; };
}
TEST(GeolocationDeviceDataProviderWifiData, CreateDestroy) { TEST(GeolocationDeviceDataProviderWifiData, CreateDestroy) {
// See http://crbug.com/59913 . The main_message_loop is not required to be // See http://crbug.com/59913 . The main_message_loop is not required to be
...@@ -38,3 +38,5 @@ TEST(GeolocationDeviceDataProviderWifiData, CreateDestroy) { ...@@ -38,3 +38,5 @@ TEST(GeolocationDeviceDataProviderWifiData, CreateDestroy) {
} }
} }
} }
} // namespace
...@@ -17,6 +17,8 @@ using testing::DoDefault; ...@@ -17,6 +17,8 @@ using testing::DoDefault;
using testing::Invoke; using testing::Invoke;
using testing::Return; using testing::Return;
namespace {
class MockGatewayApi : public GatewayDataProviderCommon::GatewayApiInterface { class MockGatewayApi : public GatewayDataProviderCommon::GatewayApiInterface {
public: public:
MockGatewayApi() { MockGatewayApi() {
...@@ -185,3 +187,5 @@ TEST_F(GeolocationGatewayDataProviderCommonTest, DoScanWithResults) { ...@@ -185,3 +187,5 @@ TEST_F(GeolocationGatewayDataProviderCommonTest, DoScanWithResults) {
EXPECT_EQ(1, static_cast<int>(data.router_data.size())); EXPECT_EQ(1, static_cast<int>(data.router_data.size()));
EXPECT_EQ(single_router.mac_address, data.router_data.begin()->mac_address); EXPECT_EQ(single_router.mac_address, data.router_data.begin()->mac_address);
} }
} // namespace
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "net/test/test_server.h" #include "net/test/test_server.h"
namespace {
// Used to block until an iframe is loaded via a javascript call. // Used to block until an iframe is loaded via a javascript call.
// Note: NavigateToURLBlockUntilNavigationsComplete doesn't seem to work for // Note: NavigateToURLBlockUntilNavigationsComplete doesn't seem to work for
// multiple embedded iframes, as notifications seem to be 'batched'. Instead, we // multiple embedded iframes, as notifications seem to be 'batched'. Instead, we
...@@ -635,3 +637,5 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_TabDestroyed) { ...@@ -635,3 +637,5 @@ IN_PROC_BROWSER_TEST_F(GeolocationBrowserTest, DISABLED_TabDestroyed) {
L"", UTF8ToWide(script)); L"", UTF8ToWide(script));
EXPECT_EQ(result, true); EXPECT_EQ(result, true);
} }
} // namespace
...@@ -15,7 +15,6 @@ namespace { ...@@ -15,7 +15,6 @@ namespace {
const GURL kUrl0("http://www.example.com"); const GURL kUrl0("http://www.example.com");
const GURL kUrl1("http://www.example1.com"); const GURL kUrl1("http://www.example1.com");
const GURL kUrl2("http://www.example2.com"); const GURL kUrl2("http://www.example2.com");
} // namespace
class GeolocationExceptionsTableModelTest : public RenderViewHostTestHarness { class GeolocationExceptionsTableModelTest : public RenderViewHostTestHarness {
public: public:
...@@ -141,3 +140,5 @@ TEST_F(GeolocationExceptionsTableModelTest, GetText) { ...@@ -141,3 +140,5 @@ TEST_F(GeolocationExceptionsTableModelTest, GetText) {
EXPECT_NE(string16::npos, EXPECT_NE(string16::npos,
text.find(content_settings_helper::OriginToString16(kUrl2))); text.find(content_settings_helper::OriginToString16(kUrl2)));
} }
} // namespace
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include "chrome/test/testing_profile.h" #include "chrome/test/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace {
// TestTabContents short-circuits TAB_CONTENTS_INFOBAR_REMOVED to call // TestTabContents short-circuits TAB_CONTENTS_INFOBAR_REMOVED to call
// InfoBarClosed() directly. We need to observe it and call InfoBarClosed() // InfoBarClosed() directly. We need to observe it and call InfoBarClosed()
// later. // later.
...@@ -421,3 +423,5 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) { ...@@ -421,3 +423,5 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) {
// Delete the tab contents. // Delete the tab contents.
DeleteContents(); DeleteContents();
} }
} // namespace
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace { namespace {
// Constants used in multiple tests. // Constants used in multiple tests.
const char kTestServerUrl[] = "https://www.geolocation.test/service"; const char kTestServerUrl[] = "https://www.geolocation.test/service";
const char kTestHost[] = "myclienthost.test"; const char kTestHost[] = "myclienthost.test";
...@@ -21,8 +22,6 @@ const char kTestHostUrl[] = "http://myclienthost.test/some/path"; ...@@ -21,8 +22,6 @@ const char kTestHostUrl[] = "http://myclienthost.test/some/path";
// Using #define so we can easily paste this into various other strings. // Using #define so we can easily paste this into various other strings.
#define REFERENCE_ACCESS_TOKEN "2:k7j3G6LaL6u_lafw:4iXOeOpTh1glSXe" #define REFERENCE_ACCESS_TOKEN "2:k7j3G6LaL6u_lafw:4iXOeOpTh1glSXe"
} // namespace
// Stops the specified (nested) message loop when the listener is called back. // Stops the specified (nested) message loop when the listener is called back.
class MessageLoopQuitListener class MessageLoopQuitListener
: public LocationProviderBase::ListenerInterface { : public LocationProviderBase::ListenerInterface {
...@@ -779,3 +778,4 @@ TEST_F(GeolocationNetworkProviderTest, NetworkPositionCache) { ...@@ -779,3 +778,4 @@ TEST_F(GeolocationNetworkProviderTest, NetworkPositionCache) {
} }
} }
} // namespace
...@@ -19,6 +19,8 @@ using testing::DoDefault; ...@@ -19,6 +19,8 @@ using testing::DoDefault;
using testing::Invoke; using testing::Invoke;
using testing::Return; using testing::Return;
namespace {
class MockWlanApi : public WifiDataProviderCommon::WlanApiInterface { class MockWlanApi : public WifiDataProviderCommon::WlanApiInterface {
public: public:
MockWlanApi() : calls_(0), bool_return_(true) { MockWlanApi() : calls_(0), bool_return_(true) {
...@@ -225,3 +227,6 @@ TEST_F(GeolocationWifiDataProviderCommonTest, ...@@ -225,3 +227,6 @@ TEST_F(GeolocationWifiDataProviderCommonTest,
DeviceDataProvider<WifiData>::Unregister(&quit_listener); DeviceDataProvider<WifiData>::Unregister(&quit_listener);
DeviceDataProvider<WifiData>::ResetFactory(); DeviceDataProvider<WifiData>::ResetFactory();
} }
} // namespace
...@@ -23,6 +23,8 @@ using testing::DoDefault; ...@@ -23,6 +23,8 @@ using testing::DoDefault;
using testing::Invoke; using testing::Invoke;
using testing::Return; using testing::Return;
namespace {
class MockLatLongReport : public ILatLongReport { class MockLatLongReport : public ILatLongReport {
public: public:
MockLatLongReport() : ref_count_(1) { MockLatLongReport() : ref_count_(1) {
...@@ -331,3 +333,5 @@ TEST_F(GeolocationApiWin7Tests, GetInvalidPosition) { ...@@ -331,3 +333,5 @@ TEST_F(GeolocationApiWin7Tests, GetInvalidPosition) {
api_->GetPosition(&position); api_->GetPosition(&position);
EXPECT_FALSE(position.IsValidFix()); EXPECT_FALSE(position.IsValidFix());
} }
} // namespace
...@@ -16,6 +16,7 @@ using testing::DoDefault; ...@@ -16,6 +16,7 @@ using testing::DoDefault;
using testing::Invoke; using testing::Invoke;
using testing::Return; using testing::Return;
namespace {
class MockWin7LocationApi : public Win7LocationApi { class MockWin7LocationApi : public Win7LocationApi {
public: public:
...@@ -136,3 +137,5 @@ TEST_F(GeolocationProviderWin7Tests, GetInvalidPosition) { ...@@ -136,3 +137,5 @@ TEST_F(GeolocationProviderWin7Tests, GetInvalidPosition) {
provider_->GetPosition(&position); provider_->GetPosition(&position);
EXPECT_FALSE(position.IsValidFix()); EXPECT_FALSE(position.IsValidFix());
} }
} // namespace
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment