diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-03 16:15:32 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-03 16:15:32 +0000 |
commit | 3896b185aa328b422ebfd002e382e0186ec3fbd7 (patch) | |
tree | d2a6db357bf72adeaff75b4953ad560e96215913 /chrome/browser/cocoa/bug_report_window_controller_unittest.mm | |
parent | 71aa3446235a444e69185f972b5cec8216f64374 (diff) | |
download | chromium_src-3896b185aa328b422ebfd002e382e0186ec3fbd7.zip chromium_src-3896b185aa328b422ebfd002e382e0186ec3fbd7.tar.gz chromium_src-3896b185aa328b422ebfd002e382e0186ec3fbd7.tar.bz2 |
Add "Report Bug" dialog to Mac OSX.
BUG= http://crbug.com/19282
TEST= Use report bug dialog on Mac OSX.
Review URL: http://codereview.chromium.org/340039
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30815 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/bug_report_window_controller_unittest.mm')
-rw-r--r-- | chrome/browser/cocoa/bug_report_window_controller_unittest.mm | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/bug_report_window_controller_unittest.mm b/chrome/browser/cocoa/bug_report_window_controller_unittest.mm new file mode 100644 index 0000000..6b15c4a --- /dev/null +++ b/chrome/browser/cocoa/bug_report_window_controller_unittest.mm @@ -0,0 +1,71 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <Cocoa/Cocoa.h> + +#include "base/ref_counted.h" +#import "chrome/browser/cocoa/bug_report_window_controller.h" +#include "chrome/browser/renderer_host/site_instance.h" +#include "chrome/browser/renderer_host/test/test_render_view_host.h" +#include "chrome/browser/tab_contents/test_tab_contents.h" +#include "chrome/browser/profile.h" + +namespace { + +class BugReportWindowControllerUnittest : public RenderViewHostTestHarness { +}; + +TEST_F(BugReportWindowControllerUnittest, ReportBugWithNewTabPageOpen) { + // Create a "chrome://newtab" test tab. SiteInstance will be deleted when + // tabContents is deleted. + SiteInstance* instance = + SiteInstance::CreateSiteInstance(profile_.get()); + TestTabContents* tabContents = new TestTabContents(profile_.get(), + instance); + tabContents->controller().LoadURL(GURL("chrome://newtab"), + GURL(), PageTransition::START_PAGE); + + BugReportWindowController* controller = [[BugReportWindowController alloc] + initWithTabContents:tabContents + profile:profile_.get()]; + + // The phishing report bug is stored at index 2 in the Report Bug dialog. + [controller setBugType:2]; + EXPECT_TRUE([controller isPhishingReport]); + [controller setBugType:1]; + EXPECT_FALSE([controller isPhishingReport]); + + // Make sure that the tab was correctly recorded. + EXPECT_TRUE([[controller pageURL] isEqualToString:@"chrome://newtab/"]); + EXPECT_TRUE([[controller pageTitle] isEqualToString:@"New Tab"]); + + // When we call "report bug" with non-empty tab contents, all menu options + // should be available, and we should send screenshot by default. + EXPECT_EQ([[controller bugTypeList] count], 8U); + EXPECT_TRUE([controller sendScreenshot]); + + delete tabContents; + [controller release]; +} + +TEST_F(BugReportWindowControllerUnittest, ReportBugWithNoWindowOpen) { + BugReportWindowController* controller = [[BugReportWindowController alloc] + initWithTabContents:NULL + profile:profile_.get()]; + + // Make sure that no page title or URL are recorded. + EXPECT_TRUE([[controller pageURL] isEqualToString:@""]); + EXPECT_TRUE([[controller pageTitle] isEqualToString:@""]); + + // When we call "report bug" with empty tab contents, only menu options + // that don't refer to a specific page should be available, and the send + // screenshot option should be turned off. + EXPECT_EQ([[controller bugTypeList] count], 4U); + EXPECT_FALSE([controller sendScreenshot]); + + [controller release]; +} + +} // namespace + |