| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/api/push_messaging/sync_setup_helper.h" | 10 #include "chrome/browser/extensions/api/push_messaging/sync_setup_helper.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 ExtensionApiTest::SetUp(); | 67 ExtensionApiTest::SetUp(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void InitializeSync() { | 70 void InitializeSync() { |
| 71 ASSERT_TRUE(sync_setup_helper_->InitializeSync(profile())); | 71 ASSERT_TRUE(sync_setup_helper_->InitializeSync(profile())); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // InProcessBrowserTest override. Destroys the sync client and sync | 74 // InProcessBrowserTest override. Destroys the sync client and sync |
| 75 // profile created by the test. We must clean up ProfileSyncServiceHarness | 75 // profile created by the test. We must clean up ProfileSyncServiceHarness |
| 76 // now before the profile is cleaned up. | 76 // now before the profile is cleaned up. |
| 77 virtual void TearDownOnMainThread() override { | 77 void TearDownOnMainThread() override { sync_setup_helper_.reset(); } |
| 78 sync_setup_helper_.reset(); | |
| 79 } | |
| 80 | 78 |
| 81 const SyncSetupHelper* sync_setup_helper() const { | 79 const SyncSetupHelper* sync_setup_helper() const { |
| 82 return sync_setup_helper_.get(); | 80 return sync_setup_helper_.get(); |
| 83 } | 81 } |
| 84 | 82 |
| 85 protected: | 83 protected: |
| 86 // Override InProcessBrowserTest. Change behavior of the default host | 84 // Override InProcessBrowserTest. Change behavior of the default host |
| 87 // resolver to avoid DNS lookup errors, so we can make network calls. | 85 // resolver to avoid DNS lookup errors, so we can make network calls. |
| 88 virtual void SetUpInProcessBrowserTestFixture() override { | 86 void SetUpInProcessBrowserTestFixture() override { |
| 89 // The resolver object lifetime is managed by sync_test_setup, not here. | 87 // The resolver object lifetime is managed by sync_test_setup, not here. |
| 90 EnableDNSLookupForThisTest( | 88 EnableDNSLookupForThisTest( |
| 91 new net::RuleBasedHostResolverProc(host_resolver())); | 89 new net::RuleBasedHostResolverProc(host_resolver())); |
| 92 } | 90 } |
| 93 | 91 |
| 94 virtual void TearDownInProcessBrowserTestFixture() override { | 92 void TearDownInProcessBrowserTestFixture() override { |
| 95 DisableDNSLookupForThisTest(); | 93 DisableDNSLookupForThisTest(); |
| 96 } | 94 } |
| 97 | 95 |
| 98 | 96 |
| 99 // Change behavior of the default host resolver to allow DNS lookup | 97 // Change behavior of the default host resolver to allow DNS lookup |
| 100 // to proceed instead of being blocked by the test infrastructure. | 98 // to proceed instead of being blocked by the test infrastructure. |
| 101 void EnableDNSLookupForThisTest( | 99 void EnableDNSLookupForThisTest( |
| 102 net::RuleBasedHostResolverProc* host_resolver) { | 100 net::RuleBasedHostResolverProc* host_resolver) { |
| 103 // mock_host_resolver_override_ takes ownership of the resolver. | 101 // mock_host_resolver_override_ takes ownership of the resolver. |
| 104 scoped_refptr<net::RuleBasedHostResolverProc> resolver = | 102 scoped_refptr<net::RuleBasedHostResolverProc> resolver = |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 "startTestWithCredentials('%s', '%s', '%s');", | 159 "startTestWithCredentials('%s', '%s', '%s');", |
| 162 client_id.c_str(), client_secret.c_str(), refresh_token.c_str())); | 160 client_id.c_str(), client_secret.c_str(), refresh_token.c_str())); |
| 163 | 161 |
| 164 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> | 162 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> |
| 165 ExecuteJavaScript(script_string); | 163 ExecuteJavaScript(script_string); |
| 166 | 164 |
| 167 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 165 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 168 } | 166 } |
| 169 | 167 |
| 170 } // namespace extensions | 168 } // namespace extensions |
| OLD | NEW |