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

Side by Side Diff: chrome/browser/history/history_browsertest.cc

Issue 976553002: Remove the '--enable-file-cookies' flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 5 years, 8 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/browsing_data/browsing_data_helper.cc ('k') | chrome/test/ppapi/ppapi_test.cc » ('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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h"
9 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/history/history_service_factory.h" 14 #include "chrome/browser/history/history_service_factory.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_commands.h" 17 #include "chrome/browser/ui/browser_commands.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
21 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
22 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
23 #include "components/history/core/browser/history_db_task.h" 24 #include "components/history/core/browser/history_db_task.h"
24 #include "components/history/core/browser/history_service.h" 25 #include "components/history/core/browser/history_service.h"
25 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
26 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
27 #include "content/public/test/test_browser_thread.h" 28 #include "content/public/test/test_browser_thread.h"
29 #include "net/test/spawned_test_server/spawned_test_server.h"
28 #include "url/gurl.h" 30 #include "url/gurl.h"
29 31
30 using content::BrowserThread; 32 using content::BrowserThread;
31 33
32 namespace { 34 namespace {
33 35
36 const base::FilePath::CharType kDocRoot[] =
37 FILE_PATH_LITERAL("chrome/test/data");
38
34 // Note: WaitableEvent is not used for synchronization between the main thread 39 // Note: WaitableEvent is not used for synchronization between the main thread
35 // and history backend thread because the history subsystem posts tasks back 40 // and history backend thread because the history subsystem posts tasks back
36 // to the main thread. Had we tried to Signal an event in such a task 41 // to the main thread. Had we tried to Signal an event in such a task
37 // and Wait for it on the main thread, the task would not run at all because 42 // and Wait for it on the main thread, the task would not run at all because
38 // the main thread would be blocked on the Wait call, resulting in a deadlock. 43 // the main thread would be blocked on the Wait call, resulting in a deadlock.
39 44
40 // A task to be scheduled on the history backend thread. 45 // A task to be scheduled on the history backend thread.
41 // Notifies the main thread after all history backend thread tasks have run. 46 // Notifies the main thread after all history backend thread tasks have run.
42 class WaitForHistoryTask : public history::HistoryDBTask { 47 class WaitForHistoryTask : public history::HistoryDBTask {
43 public: 48 public:
44 WaitForHistoryTask() {} 49 WaitForHistoryTask() {}
45 50
46 bool RunOnDBThread(history::HistoryBackend* backend, 51 bool RunOnDBThread(history::HistoryBackend* backend,
47 history::HistoryDatabase* db) override { 52 history::HistoryDatabase* db) override {
48 return true; 53 return true;
49 } 54 }
50 55
51 void DoneRunOnMainThread() override { base::MessageLoop::current()->Quit(); } 56 void DoneRunOnMainThread() override { base::MessageLoop::current()->Quit(); }
52 57
53 private: 58 private:
54 ~WaitForHistoryTask() override {} 59 ~WaitForHistoryTask() override {}
55 60
56 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask); 61 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask);
57 }; 62 };
58 63
59 } // namespace 64 } // namespace
60 65
61 class HistoryBrowserTest : public InProcessBrowserTest { 66 class HistoryBrowserTest : public InProcessBrowserTest {
62 protected: 67 protected:
63 void SetUpCommandLine(base::CommandLine* command_line) override { 68 HistoryBrowserTest()
64 command_line->AppendSwitch(switches::kEnableFileCookies); 69 : test_server_(net::SpawnedTestServer::TYPE_HTTP,
65 } 70 net::SpawnedTestServer::kLocalhost,
71 base::FilePath(kDocRoot)) {}
72
73 void SetUp() override { ASSERT_TRUE(test_server_.Start()); }
66 74
67 PrefService* GetPrefs() { 75 PrefService* GetPrefs() {
68 return GetProfile()->GetPrefs(); 76 return GetProfile()->GetPrefs();
69 } 77 }
70 78
71 Profile* GetProfile() { 79 Profile* GetProfile() {
72 return browser()->profile(); 80 return browser()->profile();
73 } 81 }
74 82
75 std::vector<GURL> GetHistoryContents() { 83 std::vector<GURL> GetHistoryContents() {
(...skipping 24 matching lines...) Expand all
100 void LoadAndWaitForURL(const GURL& url) { 108 void LoadAndWaitForURL(const GURL& url) {
101 base::string16 expected_title(base::ASCIIToUTF16("OK")); 109 base::string16 expected_title(base::ASCIIToUTF16("OK"));
102 content::TitleWatcher title_watcher( 110 content::TitleWatcher title_watcher(
103 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); 111 browser()->tab_strip_model()->GetActiveWebContents(), expected_title);
104 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); 112 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL"));
105 ui_test_utils::NavigateToURL(browser(), url); 113 ui_test_utils::NavigateToURL(browser(), url);
106 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 114 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
107 } 115 }
108 116
109 void LoadAndWaitForFile(const char* filename) { 117 void LoadAndWaitForFile(const char* filename) {
110 GURL url = ui_test_utils::GetTestUrl( 118 GURL url = test_server_.GetURL(std::string("History") + filename);
111 base::FilePath().AppendASCII("History"),
112 base::FilePath().AppendASCII(filename));
113 LoadAndWaitForURL(url); 119 LoadAndWaitForURL(url);
114 } 120 }
121
122 net::SpawnedTestServer test_server_;
115 }; 123 };
116 124
117 // Test that the browser history is saved (default setting). 125 // Test that the browser history is saved (default setting).
118 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabled) { 126 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabled) {
119 EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled)); 127 EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled));
120 128
121 EXPECT_TRUE(HistoryServiceFactory::GetForProfile( 129 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
122 GetProfile(), ServiceAccessType::EXPLICIT_ACCESS)); 130 GetProfile(), ServiceAccessType::EXPLICIT_ACCESS));
123 EXPECT_TRUE(HistoryServiceFactory::GetForProfile( 131 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
124 GetProfile(), ServiceAccessType::IMPLICIT_ACCESS)); 132 GetProfile(), ServiceAccessType::IMPLICIT_ACCESS));
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 507
500 content::WebContents* active_web_contents = 508 content::WebContents* active_web_contents =
501 browser()->tab_strip_model()->GetActiveWebContents(); 509 browser()->tab_strip_model()->GetActiveWebContents();
502 ASSERT_EQ(web_contents, active_web_contents); 510 ASSERT_EQ(web_contents, active_web_contents);
503 ASSERT_EQ(history_url, active_web_contents->GetURL()); 511 ASSERT_EQ(history_url, active_web_contents->GetURL());
504 512
505 content::WebContents* second_tab = 513 content::WebContents* second_tab =
506 browser()->tab_strip_model()->GetWebContentsAt(1); 514 browser()->tab_strip_model()->GetWebContentsAt(1);
507 ASSERT_NE(history_url, second_tab->GetURL()); 515 ASSERT_NE(history_url, second_tab->GetURL());
508 } 516 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_helper.cc ('k') | chrome/test/ppapi/ppapi_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698