Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/browser/extensions/api/push_messaging/push_messaging_canary_test.cc

Issue 555633003: Use extensions::ResultCatcher; delete ExtensionApiTest::ResultCatcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/extensions/extension_apitest.h" 11 #include "chrome/browser/extensions/extension_apitest.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/render_frame_host.h" 17 #include "content/public/browser/render_frame_host.h"
18 #include "extensions/common/extension_set.h" 18 #include "extensions/common/extension_set.h"
19 #include "extensions/test/result_catcher.h"
19 #include "net/dns/mock_host_resolver.h" 20 #include "net/dns/mock_host_resolver.h"
20 21
21 namespace { 22 namespace {
22 const char kTestExtensionId[] = "mfaehphpebmlbfdiegjnpidmibldjbjk"; 23 const char kTestExtensionId[] = "mfaehphpebmlbfdiegjnpidmibldjbjk";
23 const char kPasswordFileForTest[] = "password-file-for-test"; 24 const char kPasswordFileForTest[] = "password-file-for-test";
24 const char kOverrideUserDataDir[] = "override-user-data-dir"; 25 const char kOverrideUserDataDir[] = "override-user-data-dir";
25 } // namespace 26 } // namespace
26 27
27 namespace extensions { 28 namespace extensions {
28 29
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 138
138 const ExtensionSet* installed_extensions = extension_service()->extensions(); 139 const ExtensionSet* installed_extensions = extension_service()->extensions();
139 if (!installed_extensions->Contains(kTestExtensionId)) { 140 if (!installed_extensions->Contains(kTestExtensionId)) {
140 const Extension* extension = 141 const Extension* extension =
141 LoadExtension(test_data_dir_.AppendASCII("push_messaging_canary")); 142 LoadExtension(test_data_dir_.AppendASCII("push_messaging_canary"));
142 ASSERT_TRUE(extension); 143 ASSERT_TRUE(extension);
143 } 144 }
144 ASSERT_TRUE(installed_extensions->Contains(kTestExtensionId)); 145 ASSERT_TRUE(installed_extensions->Contains(kTestExtensionId));
145 146
146 ResultCatcher catcher; 147 ResultCatcher catcher;
147 catcher.RestrictToProfile(profile()); 148 catcher.RestrictToBrowserContext(profile());
148 149
149 const Extension* extension = 150 const Extension* extension =
150 extension_service()->extensions()->GetByID(kTestExtensionId); 151 extension_service()->extensions()->GetByID(kTestExtensionId);
151 ASSERT_TRUE(extension); 152 ASSERT_TRUE(extension);
152 ui_test_utils::NavigateToURL( 153 ui_test_utils::NavigateToURL(
153 browser(), extension->GetResourceURL("push_messaging_canary.html")); 154 browser(), extension->GetResourceURL("push_messaging_canary.html"));
154 155
155 const std::string& client_id = sync_setup_helper()->client_id(); 156 const std::string& client_id = sync_setup_helper()->client_id();
156 const std::string& client_secret = sync_setup_helper()->client_secret(); 157 const std::string& client_secret = sync_setup_helper()->client_secret();
157 const std::string& refresh_token = sync_setup_helper()->refresh_token(); 158 const std::string& refresh_token = sync_setup_helper()->refresh_token();
158 159
159 const base::string16& script_string = base::UTF8ToUTF16(base::StringPrintf( 160 const base::string16& script_string = base::UTF8ToUTF16(base::StringPrintf(
160 "startTestWithCredentials('%s', '%s', '%s');", 161 "startTestWithCredentials('%s', '%s', '%s');",
161 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()));
162 163
163 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()-> 164 browser()->tab_strip_model()->GetActiveWebContents()->GetMainFrame()->
164 ExecuteJavaScript(script_string); 165 ExecuteJavaScript(script_string);
165 166
166 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 167 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
167 } 168 }
168 169
169 } // namespace extensions 170 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698