| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chromeos/login/helper.h" | 10 #include "chrome/browser/chromeos/login/helper.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 public: | 72 public: |
| 73 TestListener(const std::string& message, const base::Closure& callback) | 73 TestListener(const std::string& message, const base::Closure& callback) |
| 74 : message_(message), callback_(callback) { | 74 : message_(message), callback_(callback) { |
| 75 registrar_.Add(this, | 75 registrar_.Add(this, |
| 76 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, | 76 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, |
| 77 content::NotificationService::AllSources()); | 77 content::NotificationService::AllSources()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual void Observe(int type, | 80 virtual void Observe(int type, |
| 81 const content::NotificationSource& /* source */, | 81 const content::NotificationSource& /* source */, |
| 82 const content::NotificationDetails& details) OVERRIDE { | 82 const content::NotificationDetails& details) override { |
| 83 const std::string& message = *content::Details<std::string>(details).ptr(); | 83 const std::string& message = *content::Details<std::string>(details).ptr(); |
| 84 if (message == message_) | 84 if (message == message_) |
| 85 callback_.Run(); | 85 callback_.Run(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 private: | 88 private: |
| 89 std::string message_; | 89 std::string message_; |
| 90 base::Closure callback_; | 90 base::Closure callback_; |
| 91 | 91 |
| 92 content::NotificationRegistrar registrar_; | 92 content::NotificationRegistrar registrar_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(TestListener); | 94 DISALLOW_COPY_AND_ASSIGN(TestListener); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest { | 97 class NetworkingPrivateChromeOSApiTest : public ExtensionApiTest { |
| 98 public: | 98 public: |
| 99 NetworkingPrivateChromeOSApiTest() | 99 NetworkingPrivateChromeOSApiTest() |
| 100 : detector_(NULL), | 100 : detector_(NULL), |
| 101 service_test_(NULL), | 101 service_test_(NULL), |
| 102 manager_test_(NULL), | 102 manager_test_(NULL), |
| 103 device_test_(NULL) {} | 103 device_test_(NULL) {} |
| 104 | 104 |
| 105 bool RunNetworkingSubtest(const std::string& subtest) { | 105 bool RunNetworkingSubtest(const std::string& subtest) { |
| 106 return RunExtensionSubtest("networking", | 106 return RunExtensionSubtest("networking", |
| 107 "main.html?" + subtest, | 107 "main.html?" + subtest, |
| 108 kFlagEnableFileAccess | kFlagLoadAsComponent); | 108 kFlagEnableFileAccess | kFlagLoadAsComponent); |
| 109 } | 109 } |
| 110 | 110 |
| 111 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 111 virtual void SetUpInProcessBrowserTestFixture() override { |
| 112 EXPECT_CALL(provider_, IsInitializationComplete(_)) | 112 EXPECT_CALL(provider_, IsInitializationComplete(_)) |
| 113 .WillRepeatedly(Return(true)); | 113 .WillRepeatedly(Return(true)); |
| 114 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); | 114 policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_); |
| 115 | 115 |
| 116 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 116 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 static void AssignString(std::string* out, | 119 static void AssignString(std::string* out, |
| 120 DBusMethodCallStatus call_status, | 120 DBusMethodCallStatus call_status, |
| 121 const std::string& result) { | 121 const std::string& result) { |
| 122 CHECK_EQ(call_status, DBUS_METHOD_CALL_SUCCESS); | 122 CHECK_EQ(call_status, DBUS_METHOD_CALL_SUCCESS); |
| 123 *out = result; | 123 *out = result; |
| 124 } | 124 } |
| 125 | 125 |
| 126 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 126 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 127 ExtensionApiTest::SetUpCommandLine(command_line); | 127 ExtensionApiTest::SetUpCommandLine(command_line); |
| 128 // Whitelist the extension ID of the test extension. | 128 // Whitelist the extension ID of the test extension. |
| 129 command_line->AppendSwitchASCII( | 129 command_line->AppendSwitchASCII( |
| 130 extensions::switches::kWhitelistedExtensionID, | 130 extensions::switches::kWhitelistedExtensionID, |
| 131 "epcifkihnkjgphfkloaaleeakhpmgdmn"); | 131 "epcifkihnkjgphfkloaaleeakhpmgdmn"); |
| 132 | 132 |
| 133 // TODO(pneubeck): Remove the following hack, once the NetworkingPrivateAPI | 133 // TODO(pneubeck): Remove the following hack, once the NetworkingPrivateAPI |
| 134 // uses the ProfileHelper to obtain the userhash crbug/238623. | 134 // uses the ProfileHelper to obtain the userhash crbug/238623. |
| 135 const std::string login_user = chromeos::login::CanonicalizeUserID( | 135 const std::string login_user = chromeos::login::CanonicalizeUserID( |
| 136 command_line->GetSwitchValueNative(chromeos::switches::kLoginUser)); | 136 command_line->GetSwitchValueNative(chromeos::switches::kLoginUser)); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 const std::string& type, | 189 const std::string& type, |
| 190 const std::string& state) { | 190 const std::string& state) { |
| 191 service_test_->AddService(service_path, | 191 service_test_->AddService(service_path, |
| 192 service_path + "_guid", | 192 service_path + "_guid", |
| 193 name, | 193 name, |
| 194 type, | 194 type, |
| 195 state, | 195 state, |
| 196 true /* add_to_visible */); | 196 true /* add_to_visible */); |
| 197 } | 197 } |
| 198 | 198 |
| 199 virtual void SetUpOnMainThread() OVERRIDE { | 199 virtual void SetUpOnMainThread() override { |
| 200 detector_ = new NetworkPortalDetectorTestImpl(); | 200 detector_ = new NetworkPortalDetectorTestImpl(); |
| 201 NetworkPortalDetector::InitializeForTesting(detector_); | 201 NetworkPortalDetector::InitializeForTesting(detector_); |
| 202 | 202 |
| 203 ExtensionApiTest::SetUpOnMainThread(); | 203 ExtensionApiTest::SetUpOnMainThread(); |
| 204 content::RunAllPendingInMessageLoop(); | 204 content::RunAllPendingInMessageLoop(); |
| 205 | 205 |
| 206 InitializeSanitizedUsername(); | 206 InitializeSanitizedUsername(); |
| 207 | 207 |
| 208 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); | 208 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); |
| 209 manager_test_ = dbus_manager->GetShillManagerClient()->GetTestInterface(); | 209 manager_test_ = dbus_manager->GetShillManagerClient()->GetTestInterface(); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 detector()->SetDetectionResultsForTesting("wifi_guid", state); | 526 detector()->SetDetectionResultsForTesting("wifi_guid", state); |
| 527 | 527 |
| 528 TestListener listener( | 528 TestListener listener( |
| 529 "notifyPortalDetectorObservers", | 529 "notifyPortalDetectorObservers", |
| 530 base::Bind(&NetworkPortalDetectorTestImpl::NotifyObserversForTesting, | 530 base::Bind(&NetworkPortalDetectorTestImpl::NotifyObserversForTesting, |
| 531 base::Unretained(detector()))); | 531 base::Unretained(detector()))); |
| 532 EXPECT_TRUE(RunNetworkingSubtest("captivePortalNotification")) << message_; | 532 EXPECT_TRUE(RunNetworkingSubtest("captivePortalNotification")) << message_; |
| 533 } | 533 } |
| 534 | 534 |
| 535 } // namespace | 535 } // namespace |
| OLD | NEW |