• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/extensions/extension_apitest.h"
6 #include "content/browser/geolocation/location_arbitrator.h"
7 #include "content/browser/geolocation/mock_location_provider.h"
8 #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h"
9 
10 class GeolocationApiTest : public ExtensionApiTest {
11  public:
GeolocationApiTest()12   GeolocationApiTest()
13       : dependency_factory_(
14           new GeolocationArbitratorDependencyFactoryWithLocationProvider(
15               &NewAutoSuccessMockLocationProvider)) {
16   }
17 
18   // InProcessBrowserTest
SetUpInProcessBrowserTestFixture()19   virtual void SetUpInProcessBrowserTestFixture() {
20     ExtensionApiTest::SetUpInProcessBrowserTestFixture();
21     GeolocationArbitrator::SetDependencyFactoryForTest(
22         dependency_factory_.get());
23   }
24 
25   // InProcessBrowserTest
TearDownInProcessBrowserTestFixture()26   virtual void TearDownInProcessBrowserTestFixture() {
27     GeolocationArbitrator::SetDependencyFactoryForTest(NULL);
28   }
29 
30  private:
31   scoped_refptr<GeolocationArbitratorDependencyFactory> dependency_factory_;
32 };
33 
IN_PROC_BROWSER_TEST_F(GeolocationApiTest,FLAKY_ExtensionGeolocationAccessFail)34 IN_PROC_BROWSER_TEST_F(GeolocationApiTest,
35                        FLAKY_ExtensionGeolocationAccessFail) {
36   // Test that geolocation cannot be accessed from extension without permission.
37   ASSERT_TRUE(RunExtensionTest("geolocation/no_permission")) << message_;
38 }
39 
IN_PROC_BROWSER_TEST_F(GeolocationApiTest,ExtensionGeolocationAccessPass)40 IN_PROC_BROWSER_TEST_F(GeolocationApiTest, ExtensionGeolocationAccessPass) {
41   // Test that geolocation can be accessed from extension with permission.
42   ASSERT_TRUE(RunExtensionTest("geolocation/has_permission")) << message_;
43 }
44