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

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

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Rebase. Created 5 years, 1 month 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 <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/files/file_path.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/app/chrome_command_ids.h" 13 #include "chrome/app/chrome_command_ids.h"
14 #include "chrome/browser/history/history_service_factory.h" 14 #include "chrome/browser/history/history_service_factory.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_commands.h" 17 #include "chrome/browser/ui/browser_commands.h"
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
22 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
24 #include "components/history/core/browser/history_db_task.h" 24 #include "components/history/core/browser/history_db_task.h"
25 #include "components/history/core/browser/history_service.h" 25 #include "components/history/core/browser/history_service.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "content/public/test/browser_test_utils.h" 27 #include "content/public/test/browser_test_utils.h"
28 #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" 29 #include "net/test/embedded_test_server/embedded_test_server.h"
30 #include "url/gurl.h" 30 #include "url/gurl.h"
31 31
32 using content::BrowserThread; 32 using content::BrowserThread;
33 33
34 namespace { 34 namespace {
35 35
36 const base::FilePath::CharType kDocRoot[] = 36 const base::FilePath::CharType kDocRoot[] =
37 FILE_PATH_LITERAL("chrome/test/data"); 37 FILE_PATH_LITERAL("chrome/test/data");
38 38
39 // Note: WaitableEvent is not used for synchronization between the main thread 39 // Note: WaitableEvent is not used for synchronization between the main thread
(...skipping 20 matching lines...) Expand all
60 private: 60 private:
61 ~WaitForHistoryTask() override {} 61 ~WaitForHistoryTask() override {}
62 62
63 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask); 63 DISALLOW_COPY_AND_ASSIGN(WaitForHistoryTask);
64 }; 64 };
65 65
66 } // namespace 66 } // namespace
67 67
68 class HistoryBrowserTest : public InProcessBrowserTest { 68 class HistoryBrowserTest : public InProcessBrowserTest {
69 protected: 69 protected:
70 HistoryBrowserTest() 70 HistoryBrowserTest() : test_server_() {
71 : test_server_(net::SpawnedTestServer::TYPE_HTTP, 71 test_server_.ServeFilesFromSourceDirectory(base::FilePath(kDocRoot));
72 net::SpawnedTestServer::kLocalhost, 72 }
73 base::FilePath(kDocRoot)) {}
74 73
75 void SetUp() override { 74 void SetUp() override {
76 ASSERT_TRUE(test_server_.Start()); 75 ASSERT_TRUE(test_server_.Start());
77 InProcessBrowserTest::SetUp(); 76 InProcessBrowserTest::SetUp();
78 } 77 }
79 78
80 PrefService* GetPrefs() { 79 PrefService* GetPrefs() {
81 return GetProfile()->GetPrefs(); 80 return GetProfile()->GetPrefs();
82 } 81 }
83 82
(...skipping 29 matching lines...) Expand all
113 void LoadAndWaitForURL(const GURL& url) { 112 void LoadAndWaitForURL(const GURL& url) {
114 base::string16 expected_title(base::ASCIIToUTF16("OK")); 113 base::string16 expected_title(base::ASCIIToUTF16("OK"));
115 content::TitleWatcher title_watcher( 114 content::TitleWatcher title_watcher(
116 browser()->tab_strip_model()->GetActiveWebContents(), expected_title); 115 browser()->tab_strip_model()->GetActiveWebContents(), expected_title);
117 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); 116 title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL"));
118 ui_test_utils::NavigateToURL(browser(), url); 117 ui_test_utils::NavigateToURL(browser(), url);
119 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 118 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
120 } 119 }
121 120
122 void LoadAndWaitForFile(const char* filename) { 121 void LoadAndWaitForFile(const char* filename) {
123 GURL url = test_server_.GetURL(std::string("History") + filename); 122 GURL url = test_server_.GetURL(std::string("/History") + filename);
124 LoadAndWaitForURL(url); 123 LoadAndWaitForURL(url);
125 } 124 }
126 125
127 net::SpawnedTestServer test_server_; 126 net::EmbeddedTestServer test_server_;
128 }; 127 };
129 128
130 // Test that the browser history is saved (default setting). 129 // Test that the browser history is saved (default setting).
131 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabled) { 130 IN_PROC_BROWSER_TEST_F(HistoryBrowserTest, SavingHistoryEnabled) {
132 EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled)); 131 EXPECT_FALSE(GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled));
133 132
134 EXPECT_TRUE(HistoryServiceFactory::GetForProfile( 133 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
135 GetProfile(), ServiceAccessType::EXPLICIT_ACCESS)); 134 GetProfile(), ServiceAccessType::EXPLICIT_ACCESS));
136 EXPECT_TRUE(HistoryServiceFactory::GetForProfile( 135 EXPECT_TRUE(HistoryServiceFactory::GetForProfile(
137 GetProfile(), ServiceAccessType::IMPLICIT_ACCESS)); 136 GetProfile(), ServiceAccessType::IMPLICIT_ACCESS));
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 521
523 content::WebContents* active_web_contents = 522 content::WebContents* active_web_contents =
524 browser()->tab_strip_model()->GetActiveWebContents(); 523 browser()->tab_strip_model()->GetActiveWebContents();
525 ASSERT_EQ(web_contents, active_web_contents); 524 ASSERT_EQ(web_contents, active_web_contents);
526 ASSERT_EQ(history_url, active_web_contents->GetURL()); 525 ASSERT_EQ(history_url, active_web_contents->GetURL());
527 526
528 content::WebContents* second_tab = 527 content::WebContents* second_tab =
529 browser()->tab_strip_model()->GetWebContentsAt(1); 528 browser()->tab_strip_model()->GetWebContentsAt(1);
530 ASSERT_NE(history_url, second_tab->GetURL()); 529 ASSERT_NE(history_url, second_tab->GetURL());
531 } 530 }
OLDNEW
« no previous file with comments | « chrome/browser/geolocation/geolocation_browsertest.cc ('k') | chrome/browser/history/redirect_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698