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

Side by Side Diff: chrome/browser/ui/webui/print_preview_browsertest.cc

Issue 7237030: Added options browser_tests using the generator and js handler framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows doesn't allow OVERRIDE on destructors. Created 9 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) 2011 The Chromium Authors. All rights reserved. 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 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/webui/web_ui_browsertest.h" 10 #include "chrome/browser/ui/webui/web_ui_browsertest.h"
(...skipping 16 matching lines...) Expand all
27 load_start_observer); 27 load_start_observer);
28 TabContents* initiator_tab_contents = browser->GetSelectedTabContents(); 28 TabContents* initiator_tab_contents = browser->GetSelectedTabContents();
29 browser->Print(); 29 browser->Print();
30 tabstrip_observer.WaitForObservation(); 30 tabstrip_observer.WaitForObservation();
31 EXPECT_NE(initiator_tab_contents, browser->GetSelectedTabContents()); 31 EXPECT_NE(initiator_tab_contents, browser->GetSelectedTabContents());
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
36 class PrintPreviewWebUITest 36 class PrintPreviewWebUITest
37 : public WebUIBrowserTest, 37 : public WebUIBrowserTest {
38 public TestTabStripModelObserver::LoadStartObserver {
39 protected: 38 protected:
40 // WebUIBrowserTest: 39 // WebUIBrowserTest:
41 virtual void SetUpOnMainThread() OVERRIDE { 40 virtual void SetUpOnMainThread() OVERRIDE {
42 WebUIBrowserTest::SetUpOnMainThread(); 41 WebUIBrowserTest::SetUpOnMainThread();
43 if (!HasPDFLib()) 42 if (!HasPDFLib())
44 skipTest(base::StringPrintf("%s:%d: No PDF Lib.", __FILE__, __LINE__)); 43 skipTest(base::StringPrintf("%s:%d: No PDF Lib.", __FILE__, __LINE__));
45 44
45 override_chrome_send_ = true;
46 AddLibrary(FilePath(FILE_PATH_LITERAL("print_preview.js"))); 46 AddLibrary(FilePath(FILE_PATH_LITERAL("print_preview.js")));
47 GURL print_preview_test_url = WebUITestDataPathToURL( 47 GURL print_preview_test_url = WebUITestDataPathToURL(
48 FILE_PATH_LITERAL("print_preview_hello_world_test.html")); 48 FILE_PATH_LITERAL("print_preview_hello_world_test.html"));
49 ui_test_utils::NavigateToURL(browser(), print_preview_test_url); 49 ui_test_utils::NavigateToURL(browser(), print_preview_test_url);
50 PrintAndWaitForPrintPreviewTab(browser(), this); 50 PrintAndWaitForPrintPreviewTab(browser(), this);
51 } 51 }
52 52
53 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 53 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
54 WebUIBrowserTest::SetUpCommandLine(command_line); 54 WebUIBrowserTest::SetUpCommandLine(command_line);
55 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 55 #if !defined(GOOGLE_CHROME_BUILD) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
56 // Don't enable the flag for chrome builds, which should be on by default. 56 // Don't enable the flag for chrome builds, which should be on by default.
57 command_line->AppendSwitch(switches::kEnablePrintPreview); 57 command_line->AppendSwitch(switches::kEnablePrintPreview);
58 #else 58 #else
59 ASSERT_TRUE(switches::IsPrintPreviewEnabled()); 59 ASSERT_TRUE(switches::IsPrintPreviewEnabled());
60 #endif 60 #endif
61 } 61 }
62 62
63 // TestTabStripModelObserver::LoadStartObserver:
64 virtual void OnLoadStart() OVERRIDE {
65 PreLoadJavascriptLibraries(true);
66 }
67
68 bool HasPDFLib() const { 63 bool HasPDFLib() const {
69 FilePath pdf; 64 FilePath pdf;
70 return PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf) && 65 return PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf) &&
71 file_util::PathExists(pdf); 66 file_util::PathExists(pdf);
72 } 67 }
73 }; 68 };
74 69
75 IN_PROC_BROWSER_TEST_F(PrintPreviewWebUITest, FLAKY_TestPrintPreview) { 70 IN_PROC_BROWSER_TEST_F(PrintPreviewWebUITest, FLAKY_TestPrintPreview) {
76 ASSERT_TRUE(RunJavascriptTest("testPrintPreview", 71 ASSERT_TRUE(RunJavascriptTest("testPrintPreview",
77 *Value::CreateBooleanValue(HasPDFLib()))); 72 *Value::CreateBooleanValue(HasPDFLib())));
78 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698