Index: chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
diff --git a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
index ebac61c0ec78df7fde0a93d70772ba3c17ce6d32..436ec8db6576da9d55386c44ce4f6c4f5ac88f8a 100644 |
--- a/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
+++ b/chrome/browser/extensions/api/networking_private/networking_private_apitest.cc |
@@ -2,10 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "base/bind.h" |
#include "base/callback.h" |
#include "base/command_line.h" |
-#include "base/macros.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chromeos/login/user.h" |
#include "chrome/browser/chromeos/login/user_manager.h" |
@@ -16,7 +14,6 @@ |
#include "testing/gmock/include/gmock/gmock.h" |
#if defined(OS_CHROMEOS) |
-#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/chromeos/net/network_portal_detector.h" |
#include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
#include "chromeos/chromeos_switches.h" |
@@ -33,10 +30,6 @@ |
#include "components/policy/core/common/mock_configuration_policy_provider.h" |
#include "components/policy/core/common/policy_map.h" |
#include "components/policy/core/common/policy_types.h" |
-#include "content/public/browser/notification_observer.h" |
-#include "content/public/browser/notification_registrar.h" |
-#include "content/public/browser/notification_service.h" |
-#include "content/public/browser/notification_source.h" |
#include "policy/policy_constants.h" |
#include "third_party/cros_system_api/dbus/service_constants.h" |
#else // !defined(OS_CHROMEOS) |
@@ -68,32 +61,6 @@ |
#if defined(OS_CHROMEOS) |
const char kUser1ProfilePath[] = "/profile/user1/shill"; |
- |
-class TestListener : public content::NotificationObserver { |
- public: |
- TestListener(const std::string& message, const base::Closure& callback) |
- : message_(message), callback_(callback) { |
- registrar_.Add(this, |
- chrome::NOTIFICATION_EXTENSION_TEST_MESSAGE, |
- content::NotificationService::AllSources()); |
- } |
- |
- virtual void Observe(int type, |
- const content::NotificationSource& /* source */, |
- const content::NotificationDetails& details) OVERRIDE { |
- const std::string& message = *content::Details<std::string>(details).ptr(); |
- if (message == message_) |
- callback_.Run(); |
- } |
- |
- private: |
- std::string message_; |
- base::Closure callback_; |
- |
- content::NotificationRegistrar registrar_; |
- |
- DISALLOW_COPY_AND_ASSIGN(TestListener); |
-}; |
#else // !defined(OS_CHROMEOS) |
// Stub Verify* methods implementation to satisfy expectations of |
@@ -124,18 +91,10 @@ |
}; |
#endif // defined(OS_CHROMEOS) |
-class ExtensionNetworkingPrivateApiTest |
- : public ExtensionApiTest, |
- public testing::WithParamInterface<bool> { |
+class ExtensionNetworkingPrivateApiTest : |
+ public ExtensionApiTest, |
+ public testing::WithParamInterface<bool> { |
public: |
- ExtensionNetworkingPrivateApiTest() |
- : |
-#if defined(OS_CHROMEOS) |
- detector_(NULL) |
-#endif |
- { |
- } |
- |
bool RunNetworkingSubtest(const std::string& subtest) { |
return RunExtensionSubtest( |
"networking", "main.html?" + subtest, |
@@ -192,9 +151,6 @@ |
} |
virtual void SetUpOnMainThread() OVERRIDE { |
- detector_ = new NetworkPortalDetectorTestImpl(); |
- NetworkPortalDetector::InitializeForTesting(detector_); |
- |
ExtensionApiTest::SetUpOnMainThread(); |
content::RunAllPendingInMessageLoop(); |
@@ -334,9 +290,6 @@ |
protected: |
#if defined(OS_CHROMEOS) |
- NetworkPortalDetectorTestImpl* detector() { return detector_; } |
- |
- NetworkPortalDetectorTestImpl* detector_; |
policy::MockConfigurationPolicyProvider provider_; |
std::string userhash_; |
#endif |
@@ -510,35 +463,23 @@ |
#if defined(OS_CHROMEOS) |
IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, |
GetCaptivePortalStatus) { |
+ NetworkPortalDetectorTestImpl* detector = new NetworkPortalDetectorTestImpl(); |
+ NetworkPortalDetector::InitializeForTesting(detector); |
NetworkPortalDetector::CaptivePortalState state; |
state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; |
- detector()->SetDetectionResultsForTesting("stub_ethernet", state); |
+ detector->SetDetectionResultsForTesting("stub_ethernet", state); |
state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE; |
- detector()->SetDetectionResultsForTesting("stub_wifi1", state); |
+ detector->SetDetectionResultsForTesting("stub_wifi1", state); |
state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
- detector()->SetDetectionResultsForTesting("stub_wifi2", state); |
+ detector->SetDetectionResultsForTesting("stub_wifi2", state); |
state.status = |
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; |
- detector()->SetDetectionResultsForTesting("stub_cellular1", state); |
+ detector->SetDetectionResultsForTesting("stub_cellular1", state); |
EXPECT_TRUE(RunNetworkingSubtest("getCaptivePortalStatus")) << message_; |
-} |
- |
-IN_PROC_BROWSER_TEST_P(ExtensionNetworkingPrivateApiTest, |
- CaptivePortalNotification) { |
- detector()->SetDefaultNetworkPathForTesting("wifi"); |
- NetworkPortalDetector::CaptivePortalState state; |
- state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; |
- detector()->SetDetectionResultsForTesting("wifi", state); |
- |
- TestListener listener( |
- "notifyPortalDetectorObservers", |
- base::Bind(&NetworkPortalDetectorTestImpl::NotifyObserversForTesting, |
- base::Unretained(detector()))); |
- EXPECT_TRUE(RunNetworkingSubtest("captivePortalNotification")) << message_; |
} |
#endif // defined(OS_CHROMEOS) |