OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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 #import <Cocoa/Cocoa.h> |
| 6 |
| 7 #include "base/ref_counted.h" |
| 8 #import "chrome/browser/cocoa/bug_report_window_controller.h" |
| 9 #include "chrome/browser/renderer_host/site_instance.h" |
| 10 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
| 11 #include "chrome/browser/tab_contents/test_tab_contents.h" |
| 12 #include "chrome/browser/profile.h" |
| 13 |
| 14 namespace { |
| 15 |
| 16 class BugReportWindowControllerUnittest : public RenderViewHostTestHarness { |
| 17 }; |
| 18 |
| 19 TEST_F(BugReportWindowControllerUnittest, ReportBugWithNewTabPageOpen) { |
| 20 // Create a "chrome://newtab" test tab. SiteInstance will be deleted when |
| 21 // tabContents is deleted. |
| 22 SiteInstance* instance = |
| 23 SiteInstance::CreateSiteInstance(profile_.get()); |
| 24 TestTabContents* tabContents = new TestTabContents(profile_.get(), |
| 25 instance); |
| 26 tabContents->controller().LoadURL(GURL("chrome://newtab"), |
| 27 GURL(), PageTransition::START_PAGE); |
| 28 |
| 29 BugReportWindowController* controller = [[BugReportWindowController alloc] |
| 30 initWithTabContents:tabContents |
| 31 profile:profile_.get()]; |
| 32 |
| 33 // The phishing report bug is stored at index 2 in the Report Bug dialog. |
| 34 [controller setBugType:2]; |
| 35 EXPECT_TRUE([controller isPhishingReport]); |
| 36 [controller setBugType:1]; |
| 37 EXPECT_FALSE([controller isPhishingReport]); |
| 38 |
| 39 // Make sure that the tab was correctly recorded. |
| 40 EXPECT_TRUE([[controller pageURL] isEqualToString:@"chrome://newtab/"]); |
| 41 EXPECT_TRUE([[controller pageTitle] isEqualToString:@"New Tab"]); |
| 42 |
| 43 // When we call "report bug" with non-empty tab contents, all menu options |
| 44 // should be available, and we should send screenshot by default. |
| 45 EXPECT_EQ([[controller bugTypeList] count], 8U); |
| 46 EXPECT_TRUE([controller sendScreenshot]); |
| 47 |
| 48 delete tabContents; |
| 49 [controller release]; |
| 50 } |
| 51 |
| 52 TEST_F(BugReportWindowControllerUnittest, ReportBugWithNoWindowOpen) { |
| 53 BugReportWindowController* controller = [[BugReportWindowController alloc] |
| 54 initWithTabContents:NULL |
| 55 profile:profile_.get()]; |
| 56 |
| 57 // Make sure that no page title or URL are recorded. |
| 58 EXPECT_TRUE([[controller pageURL] isEqualToString:@""]); |
| 59 EXPECT_TRUE([[controller pageTitle] isEqualToString:@""]); |
| 60 |
| 61 // When we call "report bug" with empty tab contents, only menu options |
| 62 // that don't refer to a specific page should be available, and the send |
| 63 // screenshot option should be turned off. |
| 64 EXPECT_EQ([[controller bugTypeList] count], 4U); |
| 65 EXPECT_FALSE([controller sendScreenshot]); |
| 66 |
| 67 [controller release]; |
| 68 } |
| 69 |
| 70 } // namespace |
| 71 |
OLD | NEW |