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

Side by Side Diff: chrome/browser/extensions/api/history/history_apitest.cc

Issue 16268017: GTTF: convert some tests in chrome to use EmbeddedTestServer patch nr 1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 5 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 | Annotate | Revision Log
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 "base/base_switches.h" 5 #include "base/base_switches.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/history/history_service.h" 10 #include "chrome/browser/history/history_service.h"
11 #include "chrome/browser/history/history_service_factory.h" 11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/history/history_types.h" 12 #include "chrome/browser/history/history_types.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
17 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 #include "net/dns/mock_host_resolver.h" 18 #include "net/dns/mock_host_resolver.h"
19 19
20 namespace extensions { 20 namespace extensions {
21 21
22 class HistoryApiTest : public ExtensionApiTest { 22 class HistoryApiTest : public ExtensionApiTest {
23 public: 23 public:
24 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 24 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
25 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); 25 ExtensionApiTest::SetUpInProcessBrowserTestFixture();
26 26
27 host_resolver()->AddRule("www.a.com", "127.0.0.1"); 27 host_resolver()->AddRule("www.a.com", "127.0.0.1");
28 host_resolver()->AddRule("www.b.com", "127.0.0.1"); 28 host_resolver()->AddRule("www.b.com", "127.0.0.1");
29
30 ASSERT_TRUE(StartTestServer());
31 } 29 }
32 30
33 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 31 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
34 ExtensionApiTest::SetUpCommandLine(command_line); 32 ExtensionApiTest::SetUpCommandLine(command_line);
35 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); 33 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
36 } 34 }
37 }; 35 };
38 36
39 // Full text search indexing sometimes exceeds a timeout. (http://crbug/119505) 37 // Full text search indexing sometimes exceeds a timeout. (http://crbug/119505)
40 IN_PROC_BROWSER_TEST_F(HistoryApiTest, DISABLED_MiscSearch) { 38 IN_PROC_BROWSER_TEST_F(HistoryApiTest, DISABLED_MiscSearch) {
39 ASSERT_TRUE(StartEmbeddedTestServer());
41 ASSERT_TRUE(RunExtensionSubtest("history", "misc_search.html")) << message_; 40 ASSERT_TRUE(RunExtensionSubtest("history", "misc_search.html")) << message_;
42 } 41 }
43 42
44 // Same could happen here without the FTS (http://crbug/119505) 43 // Same could happen here without the FTS (http://crbug/119505)
45 IN_PROC_BROWSER_TEST_F(HistoryApiTest, DISABLED_TimedSearch) { 44 IN_PROC_BROWSER_TEST_F(HistoryApiTest, DISABLED_TimedSearch) {
45 ASSERT_TRUE(StartEmbeddedTestServer());
46 ASSERT_TRUE(RunExtensionSubtest("history", "timed_search.html")) << message_; 46 ASSERT_TRUE(RunExtensionSubtest("history", "timed_search.html")) << message_;
47 } 47 }
48 48
49 #if defined(OS_WIN) 49 #if defined(OS_WIN)
50 // Flaky on Windows: crbug.com/88318 50 // Flaky on Windows: crbug.com/88318
51 #define MAYBE_Delete DISABLED_Delete 51 #define MAYBE_Delete DISABLED_Delete
52 #else 52 #else
53 #define MAYBE_Delete Delete 53 #define MAYBE_Delete Delete
54 #endif 54 #endif
55 IN_PROC_BROWSER_TEST_F(HistoryApiTest, MAYBE_Delete) { 55 IN_PROC_BROWSER_TEST_F(HistoryApiTest, MAYBE_Delete) {
56 ASSERT_TRUE(StartEmbeddedTestServer());
56 ASSERT_TRUE(RunExtensionSubtest("history", "delete.html")) << message_; 57 ASSERT_TRUE(RunExtensionSubtest("history", "delete.html")) << message_;
57 } 58 }
58 59
59 IN_PROC_BROWSER_TEST_F(HistoryApiTest, DeleteProhibited) { 60 IN_PROC_BROWSER_TEST_F(HistoryApiTest, DeleteProhibited) {
60 browser()->profile()->GetPrefs()-> 61 browser()->profile()->GetPrefs()->
61 SetBoolean(prefs::kAllowDeletingBrowserHistory, false); 62 SetBoolean(prefs::kAllowDeletingBrowserHistory, false);
63 ASSERT_TRUE(StartEmbeddedTestServer());
62 ASSERT_TRUE(RunExtensionSubtest("history", "delete_prohibited.html")) << 64 ASSERT_TRUE(RunExtensionSubtest("history", "delete_prohibited.html")) <<
63 message_; 65 message_;
64 } 66 }
65 67
66 // See crbug.com/79074 68 // See crbug.com/79074
67 IN_PROC_BROWSER_TEST_F(HistoryApiTest, DISABLED_GetVisits) { 69 IN_PROC_BROWSER_TEST_F(HistoryApiTest, DISABLED_GetVisits) {
70 ASSERT_TRUE(StartEmbeddedTestServer());
68 ASSERT_TRUE(RunExtensionSubtest("history", "get_visits.html")) << message_; 71 ASSERT_TRUE(RunExtensionSubtest("history", "get_visits.html")) << message_;
69 } 72 }
70 73
71 #if defined(OS_WIN) 74 #if defined(OS_WIN)
72 // Searching for a URL right after adding it fails on win XP. 75 // Searching for a URL right after adding it fails on win XP.
73 // Fix this as part of crbug/76170. 76 // Fix this as part of crbug/76170.
74 #define MAYBE_SearchAfterAdd DISABLED_SearchAfterAdd 77 #define MAYBE_SearchAfterAdd DISABLED_SearchAfterAdd
75 #else 78 #else
76 #define MAYBE_SearchAfterAdd SearchAfterAdd 79 #define MAYBE_SearchAfterAdd SearchAfterAdd
77 #endif 80 #endif
78 81
79 IN_PROC_BROWSER_TEST_F(HistoryApiTest, MAYBE_SearchAfterAdd) { 82 IN_PROC_BROWSER_TEST_F(HistoryApiTest, MAYBE_SearchAfterAdd) {
83 ASSERT_TRUE(StartEmbeddedTestServer());
80 ASSERT_TRUE(RunExtensionSubtest("history", "search_after_add.html")) 84 ASSERT_TRUE(RunExtensionSubtest("history", "search_after_add.html"))
81 << message_; 85 << message_;
82 } 86 }
83 87
84 IN_PROC_BROWSER_TEST_F(HistoryApiTest, MostVisited) { 88 IN_PROC_BROWSER_TEST_F(HistoryApiTest, MostVisited) {
89 ASSERT_TRUE(StartEmbeddedTestServer());
90
85 // Add entries to the history database that we can query for (using the 91 // Add entries to the history database that we can query for (using the
86 // extension history API for this doesn't work as it only adds URLs with 92 // extension history API for this doesn't work as it only adds URLs with
87 // LINK transition type). 93 // LINK transition type).
88 HistoryService* hs = HistoryServiceFactory::GetForProfile( 94 HistoryService* hs = HistoryServiceFactory::GetForProfile(
89 browser()->profile(), 95 browser()->profile(),
90 Profile::EXPLICIT_ACCESS); 96 Profile::EXPLICIT_ACCESS);
91 97
92 GURL google_url = GURL("http://www.google.com"); 98 GURL google_url = GURL("http://www.google.com");
93 base::Time google_time; 99 base::Time google_time;
94 ASSERT_TRUE(base::Time::FromString("Tue, 24 Apr 2012, 13:00:00", 100 ASSERT_TRUE(base::Time::FromString("Tue, 24 Apr 2012, 13:00:00",
95 &google_time)); 101 &google_time));
96 hs->AddPage(google_url, google_time, NULL, 0, GURL(), history::RedirectList(), 102 hs->AddPage(google_url, google_time, NULL, 0, GURL(), history::RedirectList(),
97 content::PAGE_TRANSITION_TYPED, history::SOURCE_EXTENSION, false); 103 content::PAGE_TRANSITION_TYPED, history::SOURCE_EXTENSION, false);
98 hs->SetPageTitle(google_url, UTF8ToUTF16("Google")); 104 hs->SetPageTitle(google_url, UTF8ToUTF16("Google"));
99 105
100 GURL picasa_url = GURL("http://www.picasa.com"); 106 GURL picasa_url = GURL("http://www.picasa.com");
101 base::Time picasa_time; 107 base::Time picasa_time;
102 ASSERT_TRUE(base::Time::FromString("Tue, 24 Apr 2012, 14:00:00", 108 ASSERT_TRUE(base::Time::FromString("Tue, 24 Apr 2012, 14:00:00",
103 &picasa_time)); 109 &picasa_time));
104 hs->AddPage(picasa_url, picasa_time, NULL, 0, GURL(), history::RedirectList(), 110 hs->AddPage(picasa_url, picasa_time, NULL, 0, GURL(), history::RedirectList(),
105 content::PAGE_TRANSITION_TYPED, history::SOURCE_EXTENSION, false); 111 content::PAGE_TRANSITION_TYPED, history::SOURCE_EXTENSION, false);
106 hs->SetPageTitle(picasa_url, UTF8ToUTF16("Picasa")); 112 hs->SetPageTitle(picasa_url, UTF8ToUTF16("Picasa"));
107 113
108 // Run the test. 114 // Run the test.
109 ASSERT_TRUE(RunExtensionSubtest("history", "most_visited.html")) 115 ASSERT_TRUE(RunExtensionSubtest("history", "most_visited.html"))
110 << message_; 116 << message_;
111 } 117 }
112 118
113 } // namespace extensions 119 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698