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 22 matching lines...) Expand all Loading... |
33 // checkin process. | 33 // checkin process. |
34 class PushMessagingCanaryTest : public ExtensionApiTest { | 34 class PushMessagingCanaryTest : public ExtensionApiTest { |
35 public: | 35 public: |
36 PushMessagingCanaryTest() { | 36 PushMessagingCanaryTest() { |
37 sync_setup_helper_.reset(new SyncSetupHelper()); | 37 sync_setup_helper_.reset(new SyncSetupHelper()); |
38 } | 38 } |
39 | 39 |
40 virtual ~PushMessagingCanaryTest() { | 40 virtual ~PushMessagingCanaryTest() { |
41 } | 41 } |
42 | 42 |
43 virtual void SetUp() OVERRIDE { | 43 virtual void SetUp() override { |
44 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 44 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
45 | 45 |
46 ASSERT_TRUE(command_line->HasSwitch(kPasswordFileForTest)); | 46 ASSERT_TRUE(command_line->HasSwitch(kPasswordFileForTest)); |
47 base::FilePath password_file = | 47 base::FilePath password_file = |
48 command_line->GetSwitchValuePath(kPasswordFileForTest); | 48 command_line->GetSwitchValuePath(kPasswordFileForTest); |
49 ASSERT_TRUE(sync_setup_helper_->ReadPasswordFile(password_file)); | 49 ASSERT_TRUE(sync_setup_helper_->ReadPasswordFile(password_file)); |
50 | 50 |
51 // The test framework overrides any command line user-data-dir | 51 // The test framework overrides any command line user-data-dir |
52 // argument with a /tmp/.org.chromium.Chromium.XXXXXX directory. | 52 // argument with a /tmp/.org.chromium.Chromium.XXXXXX directory. |
53 // That happens in the ChromeTestLauncherDelegate, and affects | 53 // That happens in the ChromeTestLauncherDelegate, and affects |
(...skipping 13 matching lines...) Expand all 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 virtual void TearDownOnMainThread() override { |
78 sync_setup_helper_.reset(); | 78 sync_setup_helper_.reset(); |
79 } | 79 } |
80 | 80 |
81 const SyncSetupHelper* sync_setup_helper() const { | 81 const SyncSetupHelper* sync_setup_helper() const { |
82 return sync_setup_helper_.get(); | 82 return sync_setup_helper_.get(); |
83 } | 83 } |
84 | 84 |
85 protected: | 85 protected: |
86 // Override InProcessBrowserTest. Change behavior of the default host | 86 // Override InProcessBrowserTest. Change behavior of the default host |
87 // resolver to avoid DNS lookup errors, so we can make network calls. | 87 // resolver to avoid DNS lookup errors, so we can make network calls. |
88 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 88 virtual void SetUpInProcessBrowserTestFixture() override { |
89 // The resolver object lifetime is managed by sync_test_setup, not here. | 89 // The resolver object lifetime is managed by sync_test_setup, not here. |
90 EnableDNSLookupForThisTest( | 90 EnableDNSLookupForThisTest( |
91 new net::RuleBasedHostResolverProc(host_resolver())); | 91 new net::RuleBasedHostResolverProc(host_resolver())); |
92 } | 92 } |
93 | 93 |
94 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { | 94 virtual void TearDownInProcessBrowserTestFixture() override { |
95 DisableDNSLookupForThisTest(); | 95 DisableDNSLookupForThisTest(); |
96 } | 96 } |
97 | 97 |
98 | 98 |
99 // Change behavior of the default host resolver to allow DNS lookup | 99 // Change behavior of the default host resolver to allow DNS lookup |
100 // to proceed instead of being blocked by the test infrastructure. | 100 // to proceed instead of being blocked by the test infrastructure. |
101 void EnableDNSLookupForThisTest( | 101 void EnableDNSLookupForThisTest( |
102 net::RuleBasedHostResolverProc* host_resolver) { | 102 net::RuleBasedHostResolverProc* host_resolver) { |
103 // mock_host_resolver_override_ takes ownership of the resolver. | 103 // mock_host_resolver_override_ takes ownership of the resolver. |
104 scoped_refptr<net::RuleBasedHostResolverProc> resolver = | 104 scoped_refptr<net::RuleBasedHostResolverProc> resolver = |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 "startTestWithCredentials('%s', '%s', '%s');", | 161 "startTestWithCredentials('%s', '%s', '%s');", |
162 client_id.c_str(), client_secret.c_str(), refresh_token.c_str())); | 162 client_id.c_str(), client_secret.c_str(), refresh_token.c_str())); |
163 | 163 |
164 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> | 164 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> |
165 ExecuteJavaScript(script_string); | 165 ExecuteJavaScript(script_string); |
166 | 166 |
167 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 167 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
168 } | 168 } |
169 | 169 |
170 } // namespace extensions | 170 } // namespace extensions |
OLD | NEW |