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

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: add comments 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
129 GURL ConstructTestServerURL(const char* url_template) { 130 GURL ConstructTestServerURL(const char* url_template) {
Bernhard Bauer 2015/12/04 11:06:24 This method should probably take a base::StringPie
gogerald1 2015/12/04 20:49:09 Acknowledged. Slightly prefer to use .c_str to con
130 return GURL(base::StringPrintf( 131 return GURL(base::StringPrintf(
131 url_template, embedded_test_server()->port())); 132 url_template, embedded_test_server()->port()));
132 } 133 }
133 134
134 private: 135 private:
135 scoped_ptr<net::test_server::HttpResponse> HandleRequest( 136 scoped_ptr<net::test_server::HttpResponse> HandleRequest(
136 const net::test_server::HttpRequest& request) { 137 const net::test_server::HttpRequest& request) {
137 return scoped_ptr<net::test_server::HttpResponse>( 138 return scoped_ptr<net::test_server::HttpResponse>(
138 new net::test_server::BasicHttpResponse); 139 new net::test_server::BasicHttpResponse);
139 } 140 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 host_zoom_map->SetZoomLevelForHostAndScheme(test_scheme, test_host, 237 host_zoom_map->SetZoomLevelForHostAndScheme(test_scheme, test_host,
237 new_zoom_level); 238 new_zoom_level);
238 observer.BlockUntilZoomLevelForHostHasChanged(test_host); 239 observer.BlockUntilZoomLevelForHostHasChanged(test_host);
239 EXPECT_EQ(new_zoom_level, host_zoom_map->GetZoomLevelForHostAndScheme( 240 EXPECT_EQ(new_zoom_level, host_zoom_map->GetZoomLevelForHostAndScheme(
240 test_scheme, test_host)); 241 test_scheme, test_host));
241 } 242 }
242 243
243 IN_PROC_BROWSER_TEST_F( 244 IN_PROC_BROWSER_TEST_F(
244 HostZoomMapBrowserTest, 245 HostZoomMapBrowserTest,
245 WebviewBasedSigninUsesDefaultStoragePartitionForEmbedder) { 246 WebviewBasedSigninUsesDefaultStoragePartitionForEmbedder) {
246 GURL test_url = ConstructTestServerURL(chrome::kChromeUIChromeSigninURL); 247 GURL test_url = ConstructTestServerURL(
sky 2015/12/03 22:45:28 How about a common function rather than duplicatin
gogerald1 2015/12/04 20:49:09 Done.
248 signin::GetPromoURL(signin_metrics::ACCESS_POINT_START_PAGE,
249 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false)
250 .spec()
251 .c_str());
247 std::string test_host(test_url.host()); 252 std::string test_host(test_url.host());
248 std::string test_scheme(test_url.scheme()); 253 std::string test_scheme(test_url.scheme());
249 ui_test_utils::NavigateToURL(browser(), test_url); 254 ui_test_utils::NavigateToURL(browser(), test_url);
250 255
251 content::WebContents* web_contents = 256 content::WebContents* web_contents =
252 browser()->tab_strip_model()->GetActiveWebContents(); 257 browser()->tab_strip_model()->GetActiveWebContents();
253 258
254 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); 259 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents);
255 260
256 // For the webview based sign-in code, the sign in page uses the default host 261 // For the webview based sign-in code, the sign in page uses the default host
(...skipping 17 matching lines...) Expand all
274 279
275 // Regression test for crbug.com/435017. 280 // Regression test for crbug.com/435017.
276 IN_PROC_BROWSER_TEST_F(HostZoomMapIframeSigninBrowserTest, 281 IN_PROC_BROWSER_TEST_F(HostZoomMapIframeSigninBrowserTest,
277 EventsForNonDefaultStoragePartition) { 282 EventsForNonDefaultStoragePartition) {
278 ZoomLevelChangeObserver observer(browser()->profile()); 283 ZoomLevelChangeObserver observer(browser()->profile());
279 // TODO(wjmaclean): Make this test more general by implementing a way to 284 // 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 285 // 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 286 // 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 287 // 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. 288 // be better not to rely on what the signin page is doing.
284 GURL test_url = ConstructTestServerURL(chrome::kChromeUIChromeSigninURL); 289 GURL test_url = ConstructTestServerURL(
290 signin::GetPromoURL(signin_metrics::ACCESS_POINT_START_PAGE,
291 signin_metrics::REASON_SIGNIN_PRIMARY_ACCOUNT, false)
292 .spec()
293 .c_str());
285 std::string test_host(test_url.host()); 294 std::string test_host(test_url.host());
286 std::string test_scheme(test_url.scheme()); 295 std::string test_scheme(test_url.scheme());
287 ui_test_utils::NavigateToURL(browser(), test_url); 296 ui_test_utils::NavigateToURL(browser(), test_url);
288 297
289 content::WebContents* web_contents = 298 content::WebContents* web_contents =
290 browser()->tab_strip_model()->GetActiveWebContents(); 299 browser()->tab_strip_model()->GetActiveWebContents();
291 300
292 // We are forcing non-webview based signin, so we expect the signin page to 301 // 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. 302 // be in a different storage partition, and hence a different HostZoomMap.
294 HostZoomMap* host_zoom_map = HostZoomMap::GetForWebContents(web_contents); 303 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()); 455 ZoomLevelChangeObserver observer(browser()->profile());
447 456
448 web_contents->SetPageScale(1.5); 457 web_contents->SetPageScale(1.5);
449 observer.BlockUntilZoomLevelForHostHasChanged(test_host); 458 observer.BlockUntilZoomLevelForHostHasChanged(test_host);
450 EXPECT_FALSE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); 459 EXPECT_FALSE(content::HostZoomMap::PageScaleFactorIsOne(web_contents));
451 460
452 web_contents->SetPageScale(1.f); 461 web_contents->SetPageScale(1.f);
453 observer.BlockUntilZoomLevelForHostHasChanged(test_host); 462 observer.BlockUntilZoomLevelForHostHasChanged(test_host);
454 EXPECT_TRUE(content::HostZoomMap::PageScaleFactorIsOne(web_contents)); 463 EXPECT_TRUE(content::HostZoomMap::PageScaleFactorIsOne(web_contents));
455 } 464 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698