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

Side by Side Diff: chrome/browser/ui/collected_cookies_browsertest.cc

Issue 2534743002: MacViews: Harmony for TabDialogs' dialogs (starting with Collected Cookies) (Closed)
Patch Set: Move browsertest to chrome/browser/ui + similarity=20% Created 3 years, 11 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
« no previous file with comments | « chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/command_line.h"
7 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/content_settings/cookie_settings_factory.h" 9 #include "chrome/browser/content_settings/cookie_settings_factory.h"
9 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tab_dialogs.h" 11 #include "chrome/browser/ui/tab_dialogs.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
13 #include "chrome/browser/ui/test/test_browser_dialog.h"
12 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
13 #include "chrome/test/base/in_process_browser_test.h" 15 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
15 #include "components/content_settings/core/browser/cookie_settings.h" 17 #include "components/content_settings/core/browser/cookie_settings.h"
16 #include "net/test/embedded_test_server/embedded_test_server.h" 18 #include "net/test/embedded_test_server/embedded_test_server.h"
19 #include "ui/base/ui_base_switches.h"
17 20
18 typedef InProcessBrowserTest CollectedCookiesTest; 21 class CollectedCookiesTest : public DialogBrowserTest {
22 public:
23 CollectedCookiesTest() {}
24
25 // TestDialogInterface:
26 void ShowDialog(const std::string& name) override {
27 ASSERT_TRUE(embedded_test_server()->Start());
28
29 // Disable cookies.
30 CookieSettingsFactory::GetForProfile(browser()->profile())
31 ->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
32
33 // Load a page with cookies.
34 ui_test_utils::NavigateToURL(
35 browser(), embedded_test_server()->GetURL("/cookie1.html"));
36
37 content::WebContents* web_contents =
38 browser()->tab_strip_model()->GetActiveWebContents();
39 TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
40 }
41
42 private:
43 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesTest);
44 };
45
46 // Runs with --secondary-ui-md. Users of this can switch to CollectedCookiesTest
47 // when that is the default.
48 class CollectedCookiesTestMd : public CollectedCookiesTest {
49 public:
50 CollectedCookiesTestMd() {}
51
52 // content::BrowserTestBase:
53 void SetUpCommandLine(base::CommandLine* command_line) override {
54 command_line->AppendSwitch(switches::kExtendMdToSecondaryUi);
55 }
56
57 private:
58 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesTestMd);
59 };
60
61 // Test that calls ShowDialog("default"). Interactive when run via
62 // browser_tests --gtest_filter=BrowserDialogTest.Invoke --interactive
63 // --dialog=CollectedCookiesTestMd.InvokeDialog_default
64 IN_PROC_BROWSER_TEST_F(CollectedCookiesTestMd, InvokeDialog_default) {
65 RunDialog();
66 }
19 67
20 // If this crashes on Windows, use http://crbug.com/79331 68 // If this crashes on Windows, use http://crbug.com/79331
21 IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, DoubleDisplay) { 69 IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, DoubleDisplay) {
22 ASSERT_TRUE(embedded_test_server()->Start()); 70 ShowDialog(std::string());
23 71
24 // Disable cookies. 72 // Click on the info link a second time.
25 CookieSettingsFactory::GetForProfile(browser()->profile())
26 ->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
27
28 // Load a page with cookies.
29 ui_test_utils::NavigateToURL(
30 browser(), embedded_test_server()->GetURL("/cookie1.html"));
31
32 // Click on the info link twice.
33 content::WebContents* web_contents = 73 content::WebContents* web_contents =
34 browser()->tab_strip_model()->GetActiveWebContents(); 74 browser()->tab_strip_model()->GetActiveWebContents();
35 TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies(); 75 TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
36 TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
37 } 76 }
38 77
39 // If this crashes on Windows, use http://crbug.com/79331 78 // If this crashes on Windows, use http://crbug.com/79331
40 IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, NavigateAway) { 79 IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, NavigateAway) {
41 ASSERT_TRUE(embedded_test_server()->Start()); 80 ShowDialog(std::string());
42
43 // Disable cookies.
44 CookieSettingsFactory::GetForProfile(browser()->profile())
45 ->SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
46
47 // Load a page with cookies.
48 ui_test_utils::NavigateToURL(
49 browser(), embedded_test_server()->GetURL("/cookie1.html"));
50
51 // Click on the info link.
52 content::WebContents* web_contents =
53 browser()->tab_strip_model()->GetActiveWebContents();
54 TabDialogs::FromWebContents(web_contents)->ShowCollectedCookies();
55 81
56 // Navigate to another page. 82 // Navigate to another page.
57 ui_test_utils::NavigateToURL( 83 ui_test_utils::NavigateToURL(
58 browser(), embedded_test_server()->GetURL("/cookie2.html")); 84 browser(), embedded_test_server()->GetURL("/cookie2.html"));
59 } 85 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tab_dialogs_views_mac.mm ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698