1// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/test/ui/ui_test.h" 6 7#include "app/sql/connection.h" 8#include "app/sql/statement.h" 9#include "base/file_util.h" 10#include "chrome/test/automation/tab_proxy.h" 11#include "chrome/test/automation/browser_proxy.h" 12#include "net/test/test_server.h" 13 14namespace { 15 16class MultipartResponseUITest : public UITest { 17}; 18 19#if defined(NDEBUG) 20// http://code.google.com/p/chromium/issues/detail?id=37746 21// Running this test only for release builds as it fails in debug test 22// runs 23TEST_F(MultipartResponseUITest, SingleVisit) { 24 // Make sure that visiting a multipart/x-mixed-replace site only 25 // creates one entry in the visits table. 26 net::TestServer test_server(net::TestServer::TYPE_HTTP, 27 FilePath(FILE_PATH_LITERAL("chrome/test/data"))); 28 ASSERT_TRUE(test_server.Start()); 29 30 scoped_refptr<BrowserProxy> browser_proxy(automation()->GetBrowserWindow(0)); 31 ASSERT_TRUE(browser_proxy.get()); 32 scoped_refptr<TabProxy> tab_proxy(browser_proxy->GetActiveTab()); 33 ASSERT_TRUE(tab_proxy.get()); 34 NavigateToURL(test_server.GetURL("multipart")); 35 std::wstring title; 36 EXPECT_TRUE(tab_proxy->GetTabTitle(&title)); 37 EXPECT_EQ(L"page 9", title); 38 CloseBrowserAndServer(); 39 40 // The browser has shutdown now. Check the contents of the history 41 // table. We should have only one visit for the URL even though it 42 // had 10 parts. 43 sql::Connection db; 44 FilePath history = 45 user_data_dir().AppendASCII("Default").AppendASCII("History"); 46 ASSERT_TRUE(file_util::PathExists(history)); 47 ASSERT_TRUE(db.Open(history)); 48 std::string query( 49 "SELECT COUNT(1) FROM visits, urls WHERE visits.url = urls.id" 50 " AND urls.url LIKE 'http://" + 51 test_server.host_port_pair().HostForURL() + ":%/multipart'"); 52 { 53 sql::Statement statement(db.GetUniqueStatement(query.c_str())); 54 EXPECT_TRUE(statement); 55 EXPECT_TRUE(statement.Step()); 56 EXPECT_EQ(1, statement.ColumnInt(0)); 57 } 58 db.Close(); 59} 60#endif 61 62} // namespace 63