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

Side by Side Diff: chrome/browser/profiles/host_zoom_map_browsertest.cc

Issue 1473543002: Implement newly designed sign-in related histograms for desktop platorms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: format Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/public/browser/host_zoom_map.h" 5 #include "content/public/browser/host_zoom_map.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/prefs/pref_service.h" 18 #include "base/prefs/pref_service.h"
19 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_impl.h" 22 #include "chrome/browser/profiles/profile_impl.h"
23 #include "chrome/browser/signin/signin_promo.h"
23 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" 26 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h"
26 #include "chrome/common/chrome_constants.h" 27 #include "chrome/common/chrome_constants.h"
27 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
28 #include "chrome/common/pref_names.h" 29 #include "chrome/common/pref_names.h"
29 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
30 #include "chrome/test/base/in_process_browser_test.h" 31 #include "chrome/test/base/in_process_browser_test.h"
31 #include "chrome/test/base/testing_profile.h" 32 #include "chrome/test/base/testing_profile.h"
32 #include "chrome/test/base/ui_test_utils.h" 33 #include "chrome/test/base/ui_test_utils.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 dictionaries->GetDictionary(partition_key, &values); 120 dictionaries->GetDictionary(partition_key, &values);
120 std::vector<std::string> results; 121 std::vector<std::string> results;
121 if (values) { 122 if (values) {
122 for (base::DictionaryValue::Iterator it(*values); 123 for (base::DictionaryValue::Iterator it(*values);
123 !it.IsAtEnd(); it.Advance()) 124 !it.IsAtEnd(); it.Advance())
124 results.push_back(it.key()); 125 results.push_back(it.key());
125 } 126 }
126 return results; 127 return results;
127 } 128 }
128 129
130 std::string GetSigninPromoURL() {
131 return signin::GetPromoURL(
132 signin_metrics::AccessPoint::ACCESS_POINT_START_PAGE,
133 signin_metrics::Reason::REASON_SIGNIN_PRIMARY_ACCOUNT, false)
134 .spec();
135 }
136
129 GURL ConstructTestServerURL(const char* url_template) { 137 GURL ConstructTestServerURL(const char* url_template) {
130 return GURL(base::StringPrintf( 138 return GURL(base::StringPrintf(
131 url_template, embedded_test_server()->port())); 139 url_template, embedded_test_server()->port()));
132 } 140 }
133 141
134 private: 142 private:
135 scoped_ptr<net::test_server::HttpResponse> HandleRequest( 143 scoped_ptr<net::test_server::HttpResponse> HandleRequest(
136 const net::test_server::HttpRequest& request) { 144 const net::test_server::HttpRequest& request) {
137 return scoped_ptr<net::test_server::HttpResponse>( 145 return scoped_ptr<net::test_server::HttpResponse>(
138 new net::test_server::BasicHttpResponse); 146 new net::test_server::BasicHttpResponse);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 host_zoom_map->SetZoomLevelForHostAndScheme(test_scheme, test_host, 244 host_zoom_map->SetZoomLevelForHostAndScheme(test_scheme, test_host,
237 new_zoom_level); 245 new_zoom_level);
238 observer.BlockUntilZoomLevelForHostHasChanged(test_host); 246 observer.BlockUntilZoomLevelForHostHasChanged(test_host);
239 EXPECT_EQ(new_zoom_level, host_zoom_map->GetZoomLevelForHostAndScheme( 247 EXPECT_EQ(new_zoom_level, host_zoom_map->GetZoomLevelForHostAndScheme(
240 test_scheme, test_host)); 248 test_scheme, test_host));
241 } 249 }
242 250
243 IN_PROC_BROWSER_TEST_F( 251 IN_PROC_BROWSER_TEST_F(
244 HostZoomMapBrowserTest, 252 HostZoomMapBrowserTest,
245 WebviewBasedSigninUsesDefaultStoragePartitionForEmbedder) { 253 WebviewBasedSigninUsesDefaultStoragePartitionForEmbedder) {
246 GURL test_url = ConstructTestServerURL(chrome::kChromeUIChromeSigninURL); 254 GURL test_url = ConstructTestServerURL(GetSigninPromoURL().c_str());
247 std::string test_host(test_url.host()); 255 std::string test_host(test_url.host());
248 std::string test_scheme(test_url.scheme()); 256 std::string test_scheme(test_url.scheme());
249 ui_test_utils::NavigateToURL(browser(), test_url); 257 ui_test_utils::NavigateToURL(browser(), test_url);
250 258
251 content::WebContents* web_contents = 259 content::WebContents* web_contents =
252 browser()->tab_strip_model()->GetActiveWebContents(); 260 browser()->tab_strip_model()->GetActiveWebContents();
253 261
254 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); 262 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents);
255 263
256 // For the webview based sign-in code, the sign in page uses the default host 264 // For the webview based sign-in code, the sign in page uses the default host
(...skipping 17 matching lines...) Expand all
274 282
275 // Regression test for crbug.com/435017. 283 // Regression test for crbug.com/435017.
276 IN_PROC_BROWSER_TEST_F(HostZoomMapIframeSigninBrowserTest, 284 IN_PROC_BROWSER_TEST_F(HostZoomMapIframeSigninBrowserTest,
277 EventsForNonDefaultStoragePartition) { 285 EventsForNonDefaultStoragePartition) {
278 ZoomLevelChangeObserver observer(browser()->profile()); 286 ZoomLevelChangeObserver observer(browser()->profile());
279 // TODO(wjmaclean): Make this test more general by implementing a way to 287 // TODO(wjmaclean): Make this test more general by implementing a way to
280 // force a generic URL to be loaded in a non-default storage partition. This 288 // force a generic URL to be loaded in a non-default storage partition. This
281 // test currently relies on the signin page being loaded into a non-default 289 // test currently relies on the signin page being loaded into a non-default
282 // storage partition (and verifies this is the case), but ultimately it would 290 // storage partition (and verifies this is the case), but ultimately it would
283 // be better not to rely on what the signin page is doing. 291 // be better not to rely on what the signin page is doing.
284 GURL test_url = ConstructTestServerURL(chrome::kChromeUIChromeSigninURL); 292 GURL test_url = ConstructTestServerURL(GetSigninPromoURL().c_str());
285 std::string test_host(test_url.host()); 293 std::string test_host(test_url.host());
286 std::string test_scheme(test_url.scheme()); 294 std::string test_scheme(test_url.scheme());
287 ui_test_utils::NavigateToURL(browser(), test_url); 295 ui_test_utils::NavigateToURL(browser(), test_url);
288 296
289 content::WebContents* web_contents = 297 content::WebContents* web_contents =
290 browser()->tab_strip_model()->GetActiveWebContents(); 298 browser()->tab_strip_model()->GetActiveWebContents();
291 299
292 // We are forcing non-webview based signin, so we expect the signin page to 300 // We are forcing non-webview based signin, so we expect the signin page to
293 // be in a different storage partition, and hence a different HostZoomMap. 301 // be in a different storage partition, and hence a different HostZoomMap.
294 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); 302 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 ZoomLevelChangeObserver observer(browser()->profile()); 454 ZoomLevelChangeObserver observer(browser()->profile());
447 455
448 web_contents->SetPageScale(1.5); 456 web_contents->SetPageScale(1.5);
449 observer.BlockUntilZoomLevelForHostHasChanged(test_host); 457 observer.BlockUntilZoomLevelForHostHasChanged(test_host);
450 EXPECT_FALSE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); 458 EXPECT_FALSE(content::HostZoomMap::PageScaleFactorIsOne(web_contents));
451 459
452 web_contents->SetPageScale(1.f); 460 web_contents->SetPageScale(1.f);
453 observer.BlockUntilZoomLevelForHostHasChanged(test_host); 461 observer.BlockUntilZoomLevelForHostHasChanged(test_host);
454 EXPECT_TRUE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); 462 EXPECT_TRUE(content::HostZoomMap::PageScaleFactorIsOne(web_contents));
455 } 463 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_dialog_cloud.cc ('k') | chrome/browser/resources/options/browser_options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698