Commit e8e38740 authored by jam's avatar jam Committed by Commit bot

Revert of Hook up the Mac password bubble to the browser and add browser...

Revert of Hook up the Mac password bubble to the browser and add browser tests. (patchset #8 of https://codereview.chromium.org/444603003/)

Reason for revert:
the browser tests this added are really flaky on the trybots.

see
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6541
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6582
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6576
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6574
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6573
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6572
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6567
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6566
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6565
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6564
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6561
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6557
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6556
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6554
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6554
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6549
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6548
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6544
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6544
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6541
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6539
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6537
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_swarming/builds/6530

please test this on many try runs before relanding.

Original issue's description:
> Hook up the Mac password bubble to the browser and add browser tests.
>
> BUG=328847
>
> Committed: https://chromium.googlesource.com/chromium/src/+/dae2a9adff280655fa9261b972fd62ae837b374d

TBR=dconnelly
NOTRY=true

Review URL: https://codereview.chromium.org/473423005

Cr-Commit-Position: refs/heads/master@{#291755}
parent cf57e8b1
......@@ -404,6 +404,9 @@ bool ChromePasswordManagerClient::LastLoadWasTransactionalReauthPage() const {
}
bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() {
#if !defined(USE_AURA)
return false;
#endif
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kDisableSavePasswordBubble))
return false;
......
......@@ -797,12 +797,15 @@ void Translate(Browser* browser) {
}
void ManagePasswordsForPage(Browser* browser) {
// TODO(mkwst): Implement this feature on Mac: http://crbug.com/261628
#if !defined(OS_MACOSX)
if (!browser->window()->IsActive())
return;
WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
chrome::ShowManagePasswordsBubble(web_contents);
#endif
}
void TogglePagePinnedToStartScreen(Browser* browser) {
......
......@@ -114,8 +114,12 @@ void ShowSignedCertificateTimestampsViewer(
content::WebContents* web_contents,
const content::SignedCertificateTimestampIDStatusList& sct_ids_list);
#if !defined(OS_MACOSX)
// Shows the ManagePasswords bubble for a particular |web_contents|.
//
// TODO(mkwst): Implement this feature on Mac: http://crbug.com/261628
void ShowManagePasswordsBubble(content::WebContents* web_contents);
#endif
} // namespace chrome
......
......@@ -166,9 +166,6 @@ class LocationBarViewMac : public LocationBar,
AutocompleteTextField* GetAutocompleteTextField() { return field_; }
ManagePasswordsDecoration* manage_passwords_decoration() {
return manage_passwords_decoration_.get();
}
// content::NotificationObserver:
virtual void Observe(int type,
......
......@@ -133,7 +133,7 @@ LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field,
new GeneratedCreditCardDecoration(this)),
search_button_decoration_(new SearchButtonDecoration(this)),
manage_passwords_decoration_(
new ManagePasswordsDecoration(command_updater, this)),
new ManagePasswordsDecoration(command_updater)),
browser_(browser),
weak_ptr_factory_(this) {
for (size_t i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
......@@ -222,7 +222,6 @@ void LocationBarViewMac::UpdateManagePasswordsIconAndBubble() {
return;
ManagePasswordsUIController::FromWebContents(web_contents)
->UpdateIconAndBubbleState(manage_passwords_decoration_->icon());
OnDecorationsChanged();
}
void LocationBarViewMac::UpdatePageActions() {
......@@ -527,7 +526,6 @@ NSPoint LocationBarViewMac::GetPageActionBubblePoint(
}
void LocationBarViewMac::Update(const WebContents* contents) {
UpdateManagePasswordsIconAndBubble();
UpdateStarDecorationVisibility();
UpdateTranslateDecoration();
UpdateZoomDecoration();
......
......@@ -13,7 +13,6 @@
#include "chrome/browser/ui/passwords/manage_passwords_icon.h"
class CommandUpdater;
class LocationBarViewMac;
class ManagePasswordsDecoration;
// Cocoa implementation of ManagePasswordsIcon that delegates to
......@@ -35,8 +34,7 @@ class ManagePasswordsIconCocoa : public ManagePasswordsIcon {
// password management is available on the current page.
class ManagePasswordsDecoration : public ImageDecoration {
public:
explicit ManagePasswordsDecoration(CommandUpdater* command_updater,
LocationBarViewMac* location_bar);
explicit ManagePasswordsDecoration(CommandUpdater* command_updater);
virtual ~ManagePasswordsDecoration();
// Implement |LocationBarDecoration|
......@@ -52,18 +50,9 @@ class ManagePasswordsDecoration : public ImageDecoration {
ManagePasswordsIconCocoa* icon() { return icon_.get(); }
private:
// Triggers a redraw after a state change.
void OnChange();
// Updates child view states.
void UpdateUIState();
// Shows the manage passwords bubble.
CommandUpdater* command_updater_; // Weak, owned by Browser.
// Displays all the decorations.
LocationBarViewMac* location_bar_; // Weak, owns us.
// The platform-independent interface.
scoped_ptr<ManagePasswordsIconCocoa> icon_;
......
......@@ -8,7 +8,6 @@
#include "chrome/browser/command_updater.h"
#include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
#include "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h"
#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "ui/base/l10n/l10n_util_mac.h"
// ManagePasswordsIconCocoa
......@@ -28,12 +27,10 @@ void ManagePasswordsIconCocoa::UpdateVisibleUI() {
// ManagePasswordsDecoration
ManagePasswordsDecoration::ManagePasswordsDecoration(
CommandUpdater* command_updater,
LocationBarViewMac* location_bar)
CommandUpdater* command_updater)
: command_updater_(command_updater),
location_bar_(location_bar),
icon_(new ManagePasswordsIconCocoa(this)) {
UpdateUIState();
UpdateVisibleUI();
}
ManagePasswordsDecoration::~ManagePasswordsDecoration() {}
......@@ -48,12 +45,8 @@ bool ManagePasswordsDecoration::AcceptsMousePress() {
}
bool ManagePasswordsDecoration::OnMousePressed(NSRect frame, NSPoint location) {
bool result = ImageDecoration::OnMousePressed(frame, location);
if (ManagePasswordsBubbleCocoa::instance())
ManagePasswordsBubbleCocoa::instance()->Close();
else
command_updater_->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
return result;
command_updater_->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
return true;
}
NSString* ManagePasswordsDecoration::GetToolTip() {
......@@ -62,13 +55,7 @@ NSString* ManagePasswordsDecoration::GetToolTip() {
: nil;
}
void ManagePasswordsDecoration::OnChange() {
// |location_bar_| can be NULL in tests.
if (location_bar_)
location_bar_->OnDecorationsChanged();
}
void ManagePasswordsDecoration::UpdateUIState() {
void ManagePasswordsDecoration::UpdateVisibleUI() {
if (icon_->state() == password_manager::ui::INACTIVE_STATE) {
SetVisible(false);
SetImage(nil);
......@@ -79,8 +66,3 @@ void ManagePasswordsDecoration::UpdateUIState() {
SetVisible(true);
SetImage(OmniboxViewMac::ImageForResource(icon_->icon_id()));
}
void ManagePasswordsDecoration::UpdateVisibleUI() {
UpdateUIState();
OnChange();
}
......@@ -53,8 +53,7 @@ bool ImagesEqual(NSImage* left, NSImage* right) {
class ManagePasswordsDecorationTest : public CocoaTest {
public:
ManagePasswordsDecorationTest()
: commandUpdater_(&commandDelegate_),
decoration_(&commandUpdater_, NULL) {
: commandUpdater_(&commandDelegate_), decoration_(&commandUpdater_) {
commandUpdater_.UpdateCommandEnabled(IDC_MANAGE_PASSWORDS_FOR_PAGE, true);
}
......@@ -70,7 +69,7 @@ class ManagePasswordsDecorationTest : public CocoaTest {
TEST_F(ManagePasswordsDecorationTest, ExecutesManagePasswordsCommandOnClick) {
EXPECT_TRUE(decoration()->AcceptsMousePress());
EXPECT_FALSE(decoration()->OnMousePressed(NSRect(), NSPoint()));
EXPECT_TRUE(decoration()->OnMousePressed(NSRect(), NSPoint()));
EXPECT_EQ(IDC_MANAGE_PASSWORDS_FOR_PAGE, commandDelegate()->id());
}
......
// Copyright 2014 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.
#include "base/mac/foundation_util.h"
#include "base/mac/scoped_objc_class_swizzler.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
#include "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.h"
#include "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller.h"
#include "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_pending_view_controller.h"
#include "chrome/browser/ui/passwords/manage_passwords_test.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest_mac.h"
// A helper class to swizzle [NSWindow isKeyWindow] to always return true.
@interface AlwaysKeyNSWindow : NSWindow
- (BOOL)isKeyWindow;
@end
@implementation AlwaysKeyNSWindow
- (BOOL)isKeyWindow {
return YES;
}
@end
// Integration tests for the Mac password bubble.
class ManagePasswordsBubbleTest : public ManagePasswordsTest {
public:
virtual void SetUpOnMainThread() OVERRIDE {
ManagePasswordsTest::SetUpOnMainThread();
browser()->window()->Show();
}
virtual void TearDownOnMainThread() OVERRIDE {
ManagePasswordsTest::TearDownOnMainThread();
}
ManagePasswordsBubbleController* controller() {
return ManagePasswordsBubbleCocoa::instance()
? ManagePasswordsBubbleCocoa::instance()->controller_
: nil;
}
void DoWithSwizzledNSWindow(void (^block)(void)) {
// Swizzle [NSWindow isKeyWindow] so that BrowserWindow::IsActive will
// return true and the bubble can be displayed.
base::mac::ScopedObjCClassSwizzler swizzler(
[NSWindow class], [AlwaysKeyNSWindow class], @selector(isKeyWindow));
block();
}
void DisableAnimationsOnController() {
InfoBubbleWindow* window =
base::mac::ObjCCast<InfoBubbleWindow>([controller() window]);
[window setAllowedAnimations:info_bubble::kAnimateNone];
}
ManagePasswordsDecoration* decoration() {
NSWindow* window = browser()->window()->GetNativeWindow();
BrowserWindowController* bwc =
[BrowserWindowController browserWindowControllerForWindow:window];
return [bwc locationBarBridge]->manage_passwords_decoration();
}
virtual ManagePasswordsIcon* view() OVERRIDE {
return decoration()->icon();
}
};
IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest,
PasswordEntryShowsPendingSaveView) {
EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance());
DoWithSwizzledNSWindow(^{ SetupPendingPassword(); });
EXPECT_TRUE(ManagePasswordsBubbleCocoa::instance());
EXPECT_EQ([ManagePasswordsBubblePendingViewController class],
[controller().currentController class]);
EXPECT_TRUE(view()->active());
}
IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, IconClickTogglesBubble) {
// Show the bubble automatically.
DoWithSwizzledNSWindow(^{ SetupPendingPassword(); });
// Close the bubble by clicking on the decoration.
DisableAnimationsOnController();
decoration()->OnMousePressed(NSZeroRect, NSZeroPoint);
EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance());
// Show the bubble by clicking on the decoration.
DoWithSwizzledNSWindow(^{
decoration()->OnMousePressed(NSZeroRect, NSZeroPoint);
});
EXPECT_TRUE(ManagePasswordsBubbleCocoa::instance());
}
IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, TabChangeTogglesIcon) {
// Show the bubble (and icon) automatically.
DoWithSwizzledNSWindow(^{ SetupPendingPassword(); });
EXPECT_TRUE(decoration()->IsVisible());
// Open a new tab.
int firstTab = browser()->tab_strip_model()->active_index();
AddTabAtIndex(
firstTab + 1, GURL("http://foo.bar/"), content::PAGE_TRANSITION_TYPED);
EXPECT_FALSE(decoration()->IsVisible());
// Switch back to the previous tab.
browser()->tab_strip_model()->ActivateTabAt(firstTab, true);
EXPECT_TRUE(decoration()->IsVisible());
}
......@@ -14,13 +14,8 @@ namespace content {
class WebContents;
}
namespace chrome {
void ShowManagePasswordsBubble(content::WebContents* webContents);
}
@class ManagePasswordsBubbleController;
@class ManagePasswordsBubbleCocoaNotificationBridge;
class ManagePasswordsIcon;
// Cocoa implementation of the platform-independent password bubble interface.
class ManagePasswordsBubbleCocoa : public ManagePasswordsBubble {
......@@ -28,8 +23,7 @@ class ManagePasswordsBubbleCocoa : public ManagePasswordsBubble {
// Creates and shows the bubble, which owns itself. Does nothing if the bubble
// is already shown.
static void ShowBubble(content::WebContents* webContents,
DisplayReason displayReason,
ManagePasswordsIcon* icon);
DisplayReason displayReason);
// Closes and deletes the bubble.
void Close();
......@@ -39,23 +33,16 @@ class ManagePasswordsBubbleCocoa : public ManagePasswordsBubble {
private:
friend class ManagePasswordsBubbleCocoaTest;
friend class ManagePasswordsBubbleTest;
friend void chrome::ShowManagePasswordsBubble(
content::WebContents* webContents);
// Instance-specific logic. Clients should use the static interface.
ManagePasswordsBubbleCocoa(content::WebContents* webContents,
DisplayReason displayReason,
ManagePasswordsIcon* icon);
DisplayReason displayReason);
virtual ~ManagePasswordsBubbleCocoa();
void Show();
// Cleans up state and deletes itself. Called when the bubble is closed.
void OnClose();
// The location bar icon corresponding to the bubble.
ManagePasswordsIcon* icon_;
// Whether there is currently a close operation taking place. Prevents
// multiple attempts to close the window.
bool closing_;
......
......@@ -7,11 +7,7 @@
#include "base/mac/scoped_block.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
#import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller.h"
#include "chrome/browser/ui/passwords/manage_passwords_icon.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "content/public/browser/web_contents.h"
......@@ -39,47 +35,20 @@ typedef void (^Callback)(void);
// static
ManagePasswordsBubbleCocoa* ManagePasswordsBubbleCocoa::bubble_ = NULL;
namespace chrome {
void ShowManagePasswordsBubble(content::WebContents* webContents) {
ManagePasswordsBubbleCocoa* instance = ManagePasswordsBubbleCocoa::instance();
if (instance && (instance->webContents_ != webContents)) {
// The bubble is currently shown for some other tab. We should close it now
// and open for |webContents|.
instance->Close();
}
ManagePasswordsUIController* controller =
ManagePasswordsUIController::FromWebContents(webContents);
NSWindow* window = webContents->GetTopLevelNativeWindow();
BrowserWindowController* bwc =
[BrowserWindowController browserWindowControllerForWindow:window];
ManagePasswordsBubbleCocoa::ShowBubble(
webContents,
password_manager::ui::IsAutomaticDisplayState(controller->state())
? ManagePasswordsBubble::AUTOMATIC
: ManagePasswordsBubble::USER_ACTION,
[bwc locationBarBridge]->manage_passwords_decoration()->icon());
}
} // namespace chrome
ManagePasswordsBubbleCocoa::ManagePasswordsBubbleCocoa(
content::WebContents* webContents,
DisplayReason displayReason,
ManagePasswordsIcon* icon)
DisplayReason displayReason)
: ManagePasswordsBubble(webContents, displayReason),
icon_(icon),
closing_(false),
controller_(nil),
webContents_(webContents),
bridge_(nil) {
icon_->SetActive(true);
}
ManagePasswordsBubbleCocoa::~ManagePasswordsBubbleCocoa() {
[[NSNotificationCenter defaultCenter] removeObserver:bridge_];
// Clear the global instance pointer.
bubble_ = NULL;
icon_->SetActive(false);
}
void ManagePasswordsBubbleCocoa::Show() {
......@@ -121,10 +90,9 @@ void ManagePasswordsBubbleCocoa::OnClose() {
// static
void ManagePasswordsBubbleCocoa::ShowBubble(content::WebContents* webContents,
DisplayReason displayReason,
ManagePasswordsIcon* icon) {
DisplayReason displayReason) {
if (bubble_)
return;
bubble_ = new ManagePasswordsBubbleCocoa(webContents, displayReason, icon);
bubble_ = new ManagePasswordsBubbleCocoa(webContents, displayReason);
bubble_->Show();
}
......@@ -9,13 +9,9 @@
#include "base/compiler_specific.h"
#include "base/mac/foundation_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#import "chrome/browser/ui/cocoa/browser_window_controller.h"
#include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
#include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
#include "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h"
#import "chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_controller.h"
#include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
......@@ -47,18 +43,12 @@ class ManagePasswordsBubbleCocoaTest : public CocoaProfileTest {
content::WebContents* webContents() { return webContents_; }
void ShowBubble() {
NSWindow* nativeWindow = browser()->window()->GetNativeWindow();
BrowserWindowController* bwc =
[BrowserWindowController browserWindowControllerForWindow:nativeWindow];
ManagePasswordsIcon* icon =
[bwc locationBarBridge]->manage_passwords_decoration()->icon();
ManagePasswordsBubbleCocoa::ShowBubble(
webContents(), ManagePasswordsBubble::DisplayReason::AUTOMATIC, icon);
webContents(), ManagePasswordsBubble::DisplayReason::AUTOMATIC);
// Disable animations so that closing happens immediately.
InfoBubbleWindow* bubbleWindow = base::mac::ObjCCast<InfoBubbleWindow>(
InfoBubbleWindow* window = base::mac::ObjCCast<InfoBubbleWindow>(
[ManagePasswordsBubbleCocoa::instance()->controller_ window]);
[bubbleWindow setAllowedAnimations:info_bubble::kAnimateNone];
[window setAllowedAnimations:info_bubble::kAnimateNone];
}
void CloseBubble() {
......
......@@ -6,12 +6,8 @@
#include "base/metrics/histogram_samples.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/passwords/manage_passwords_test.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_view_test.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/stub_password_manager_client.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -22,24 +18,9 @@ const char kDisplayDispositionMetric[] = "PasswordBubble.DisplayDisposition";
} // namespace
typedef ManagePasswordsViewTest ManagePasswordsBubbleViewTest;
namespace metrics_util = password_manager::metrics_util;
class ManagePasswordsBubbleViewTest : public ManagePasswordsTest {
public:
ManagePasswordsBubbleViewTest() {}
virtual ~ManagePasswordsBubbleViewTest() {}
virtual ManagePasswordsIcon* view() OVERRIDE {
BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
return browser_view->GetToolbarView()
->location_bar()
->manage_passwords_icon_view();
}
private:
DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleViewTest);
};
IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleViewTest, BasicOpenAndClose) {
EXPECT_FALSE(ManagePasswordsBubbleView::IsShowing());
ManagePasswordsBubbleView::ShowBubble(
......
......@@ -4,35 +4,16 @@
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/passwords/manage_passwords_icon.h"
#include "chrome/browser/ui/passwords/manage_passwords_test.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_view_test.h"
#include "components/password_manager/core/common/password_manager_ui.h"
#include "content/public/test/test_utils.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
class ManagePasswordsIconViewTest : public ManagePasswordsTest {
public:
ManagePasswordsIconViewTest() {}
virtual ~ManagePasswordsIconViewTest() {}
virtual ManagePasswordsIconView* view() OVERRIDE {
BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
return static_cast<ManagePasswordsIconView*>(
browser_view->GetToolbarView()
->location_bar()
->manage_passwords_icon_view());
}
private:
DISALLOW_COPY_AND_ASSIGN(ManagePasswordsIconViewTest);
};
typedef ManagePasswordsViewTest ManagePasswordsIconViewTest;
IN_PROC_BROWSER_TEST_F(ManagePasswordsIconViewTest, DefaultStateIsInactive) {
EXPECT_EQ(password_manager::ui::INACTIVE_STATE, view()->state());
......
......@@ -2,16 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/passwords/manage_passwords_test.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_view_test.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_command_controller.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/passwords/manage_passwords_icon.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
#include "chrome/browser/ui/views/passwords/manage_passwords_icon_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "components/autofill/core/common/password_form.h"
......@@ -21,7 +23,7 @@
#include "components/password_manager/core/browser/stub_password_manager_driver.h"
#include "testing/gtest/include/gtest/gtest.h"
void ManagePasswordsTest::SetUpOnMainThread() {
void ManagePasswordsViewTest::SetUpOnMainThread() {
AddTabAtIndex(0, GURL("http://example.com/"), content::PAGE_TRANSITION_TYPED);
// Create the test UIController here so that it's bound to the currently
// active WebContents.
......@@ -29,13 +31,19 @@ void ManagePasswordsTest::SetUpOnMainThread() {
browser()->tab_strip_model()->GetActiveWebContents());
}
ManagePasswordsUIControllerMock* ManagePasswordsTest::controller() {
ManagePasswordsUIControllerMock* ManagePasswordsViewTest::controller() {
return static_cast<ManagePasswordsUIControllerMock*>(
ManagePasswordsUIController::FromWebContents(
browser()->tab_strip_model()->GetActiveWebContents()));
}
void ManagePasswordsTest::ExecuteManagePasswordsCommand() {
ManagePasswordsIconView* ManagePasswordsViewTest::view() {
BrowserView* browser_view = static_cast<BrowserView*>(browser()->window());
return browser_view->GetToolbarView()->location_bar()->
manage_passwords_icon_view();
}
void ManagePasswordsViewTest::ExecuteManagePasswordsCommand() {
// Show the window to ensure that it's active.
browser()->window()->Show();
......@@ -47,7 +55,7 @@ void ManagePasswordsTest::ExecuteManagePasswordsCommand() {
content::RunAllPendingInMessageLoop();
}
void ManagePasswordsTest::SetupManagingPasswords() {
void ManagePasswordsViewTest::SetupManagingPasswords() {
base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
autofill::PasswordFormMap map;
map[kTestUsername] = test_form();
......@@ -55,7 +63,7 @@ void ManagePasswordsTest::SetupManagingPasswords() {
controller()->UpdateIconAndBubbleState(view());
}
void ManagePasswordsTest::SetupPendingPassword() {
void ManagePasswordsViewTest::SetupPendingPassword() {
password_manager::StubPasswordManagerClient client;
password_manager::StubPasswordManagerDriver driver;
scoped_ptr<password_manager::PasswordFormManager> test_form_manager(
......@@ -69,7 +77,7 @@ void ManagePasswordsTest::SetupPendingPassword() {
controller()->UpdateIconAndBubbleState(view());
}
void ManagePasswordsTest::SetupAutomaticPassword() {
void ManagePasswordsViewTest::SetupAutomaticPassword() {
password_manager::StubPasswordManagerClient client;
password_manager::StubPasswordManagerDriver driver;
scoped_ptr<password_manager::PasswordFormManager> test_form_manager(
......@@ -83,7 +91,7 @@ void ManagePasswordsTest::SetupAutomaticPassword() {
controller()->UpdateIconAndBubbleState(view());
}
void ManagePasswordsTest::SetupBlackistedPassword() {
void ManagePasswordsViewTest::SetupBlackistedPassword() {
base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
autofill::PasswordFormMap map;
map[kTestUsername] = test_form();
......@@ -91,7 +99,7 @@ void ManagePasswordsTest::SetupBlackistedPassword() {
controller()->UpdateIconAndBubbleState(view());
}
base::HistogramSamples* ManagePasswordsTest::GetSamples(
base::HistogramSamples* ManagePasswordsViewTest::GetSamples(
const char* histogram) {
// Ensure that everything has been properly recorded before pulling samples.
content::RunAllPendingInMessageLoop();
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_TEST_H_
#define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_TEST_H_
#ifndef CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_VIEW_TEST_H_
#define CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_VIEW_TEST_H_
#include "base/metrics/histogram_samples.h"
#include "base/test/histogram_tester.h"
......@@ -12,14 +12,14 @@
#include "testing/gtest/include/gtest/gtest.h"
class ManagePasswordsUIControllerMock;
class ManagePasswordsIcon;
class ManagePasswordsIconView;
// Test class for the various password management view bits and pieces. Sets
// up a ManagePasswordsUIControllerMock, and provides some helper methods
// to poke at the bubble, icon, and controller's state.
class ManagePasswordsTest : public InProcessBrowserTest {
class ManagePasswordsViewTest : public InProcessBrowserTest {
public:
ManagePasswordsTest() {}
ManagePasswordsViewTest() {}
// InProcessBrowserTest:
virtual void SetUpOnMainThread() OVERRIDE;
......@@ -28,7 +28,7 @@ class ManagePasswordsTest : public InProcessBrowserTest {
ManagePasswordsUIControllerMock* controller();
// Get the icon view for the current WebContents.
virtual ManagePasswordsIcon* view() = 0;
ManagePasswordsIconView* view();
// Execute the browser command to open the manage passwords bubble.
void ExecuteManagePasswordsCommand();
......@@ -54,7 +54,7 @@ class ManagePasswordsTest : public InProcessBrowserTest {
autofill::PasswordForm test_form_;
base::HistogramTester histogram_tester_;
DISALLOW_COPY_AND_ASSIGN(ManagePasswordsTest);
DISALLOW_COPY_AND_ASSIGN(ManagePasswordsViewTest);
};
#endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_TEST_H_
#endif // CHROME_BROWSER_UI_VIEWS_PASSWORDS_MANAGE_PASSWORDS_VIEW_TEST_H_
......@@ -111,8 +111,6 @@
'browser/ui/panels/test_panel_notification_observer.h',
'browser/ui/panels/test_panel_collection_squeeze_observer.cc',
'browser/ui/panels/test_panel_collection_squeeze_observer.h',
'browser/ui/passwords/manage_passwords_test.cc',
'browser/ui/passwords/manage_passwords_test.h',
'browser/ui/search/instant_extended_interactive_uitest.cc',
'browser/ui/pdf/pdf_interactive_browsertest.cc',
'browser/ui/search/instant_extended_manual_interactive_uitest.cc',
......@@ -140,6 +138,8 @@
'browser/ui/views/message_center/web_notification_tray_browsertest.cc',
'browser/ui/views/omnibox/omnibox_view_views_browsertest.cc',
'browser/ui/views/panels/panel_view_browsertest.cc',
'browser/ui/views/passwords/manage_passwords_view_test.cc',
'browser/ui/views/passwords/manage_passwords_view_test.h',
'browser/ui/views/passwords/manage_passwords_bubble_view_browsertest.cc',
'browser/ui/views/passwords/manage_passwords_icon_view_browsertest.cc',
'browser/ui/views/ssl_client_certificate_selector_browsertest.cc',
......@@ -1450,7 +1450,6 @@
'browser/ui/cocoa/omnibox/omnibox_view_mac_browsertest.mm',
'browser/ui/cocoa/one_click_signin_bubble_controller_browsertest.mm',
'browser/ui/cocoa/one_click_signin_dialog_controller_browsertest.mm',
'browser/ui/cocoa/passwords/manage_passwords_bubble_browsertest.mm',
'browser/ui/cocoa/profiles/profile_signin_confirmation_view_controller_browsertest.mm',
'browser/ui/cocoa/ssl_client_certificate_selector_cocoa_browsertest.mm',
'browser/ui/cocoa/view_id_util_browsertest.mm',
......@@ -1460,7 +1459,6 @@
'browser/ui/global_error/global_error_service_browsertest.cc',
'browser/ui/login/login_prompt_browsertest.cc',
'browser/ui/panels/panel_extension_browsertest.cc',
'browser/ui/passwords/manage_passwords_test.cc',
'browser/ui/pdf/pdf_browsertest.cc',
'browser/ui/prefs/prefs_tab_helper_browsertest.cc',
'browser/ui/settings_window_manager_browsertest.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment