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

Unified Diff: ash/wm/maximize_bubble_controller.cc

Issue 10855150: Revert 151485 - Adding unit tests for maximize menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/maximize_bubble_controller.h ('k') | ash/wm/workspace/frame_maximize_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/maximize_bubble_controller.cc
===================================================================
--- ash/wm/maximize_bubble_controller.cc (revision 151488)
+++ ash/wm/maximize_bubble_controller.cc (working copy)
@@ -51,6 +51,9 @@
const int kArrowHeight = 10;
const int kArrowWidth = 20;
+// The delay of the bubble appearance.
+const int kBubbleAppearanceDelayMS = 200;
+
// The animation offset in y for the bubble when appearing.
const int kBubbleAnimationOffsetY = 5;
@@ -215,7 +218,7 @@
class MaximizeBubbleController::Bubble : public views::BubbleDelegateView,
public views::MouseWatcherListener {
public:
- explicit Bubble(MaximizeBubbleController* owner, int appearance_delay_ms_);
+ explicit Bubble(MaximizeBubbleController* owner);
virtual ~Bubble() {}
// The window of the menu under which the SnapSizer will get created.
@@ -254,10 +257,6 @@
// of an asynchronous shutdown.
MaximizeBubbleController* controller() const { return owner_; }
- // Added for unit test: Retrieve the button for an action.
- // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
- views::CustomButton* GetButtonForUnitTest(SnapType state);
-
private:
// True if the shut down has been initiated.
bool shutting_down_;
@@ -280,9 +279,6 @@
// The mouse watcher which takes care of out of window hover events.
scoped_ptr<views::MouseWatcher> mouse_watcher_;
- // The fade delay - if 0 it will show / hide immediately.
- const int appearance_delay_ms_;
-
DISALLOW_COPY_AND_ASSIGN(Bubble);
};
@@ -300,12 +296,6 @@
// Called from BubbleDialogButton.
void ButtonHovered(BubbleDialogButton* sender);
- // Added for unit test: Retrieve the button for an action.
- // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
- views::CustomButton* GetButtonForUnitTest(SnapType state);
-
- MaximizeBubbleController::Bubble* bubble() { return bubble_; }
-
private:
// The owning object which gets notifications.
MaximizeBubbleController::Bubble* bubble_;
@@ -330,12 +320,6 @@
// through hover operations.
void SetSnapType(SnapType snap_type);
- // Added for unit test: Retrieve the button for an action.
- // |state| can be either SNAP_LEFT, SNAP_RIGHT or SNAP_MINIMIZE.
- views::CustomButton* GetButtonForUnitTest(SnapType state) {
- return buttons_view_->GetButtonForUnitTest(state);
- }
-
private:
// The owning class.
MaximizeBubbleController::Bubble* bubble_;
@@ -364,7 +348,6 @@
virtual void OnMouseCaptureLost() OVERRIDE;
virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
- virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
private:
// The creating class which needs to get notified in case of a hover event.
@@ -373,17 +356,14 @@
DISALLOW_COPY_AND_ASSIGN(BubbleDialogButton);
};
-MaximizeBubbleController::Bubble::Bubble(
- MaximizeBubbleController* owner,
- int appearance_delay_ms)
+MaximizeBubbleController::Bubble::Bubble(MaximizeBubbleController* owner)
: views::BubbleDelegateView(owner->frame_maximize_button(),
views::BubbleBorder::TOP_RIGHT),
shutting_down_(false),
owner_(owner),
bubble_widget_(NULL),
contents_view_(NULL),
- bubble_border_(NULL),
- appearance_delay_ms_(appearance_delay_ms) {
+ bubble_border_(NULL) {
set_margins(gfx::Insets());
// The window needs to be owned by the root so that the SnapSizer does not
@@ -422,10 +402,7 @@
// Recalculate size with new border.
SizeToContents();
- if (!appearance_delay_ms_)
- Show();
- else
- StartFade(true);
+ StartFade(true);
mouse_watcher_.reset(new views::MouseWatcher(
new BubbleMouseWatcherHost(this),
@@ -542,10 +519,7 @@
// Close the widget asynchronously after the hide animation is finished.
initial_position_ = bubble_widget_->GetNativeWindow()->bounds();
- if (!appearance_delay_ms_)
- bubble_widget_->Close();
- else
- StartFade(false);
+ StartFade(false);
}
void MaximizeBubbleController::Bubble::SetSnapType(SnapType snap_type) {
@@ -553,11 +527,6 @@
contents_view_->SetSnapType(snap_type);
}
-views::CustomButton* MaximizeBubbleController::Bubble::GetButtonForUnitTest(
- SnapType state) {
- return contents_view_->GetButtonForUnitTest(state);
-}
-
BubbleContentsButtonRow::BubbleContentsButtonRow(
MaximizeBubbleController::Bubble* bubble)
: bubble_(bubble),
@@ -617,21 +586,6 @@
bubble_->controller()->OnButtonHover(SNAP_NONE);
}
-views::CustomButton* BubbleContentsButtonRow::GetButtonForUnitTest(
- SnapType state) {
- switch (state) {
- case SNAP_LEFT:
- return left_button_;
- case SNAP_MINIMIZE:
- return minimize_button_;
- case SNAP_RIGHT:
- return right_button_;
- default:
- NOTREACHED();
- return NULL;
- }
-}
-
BubbleContentsView::BubbleContentsView(
MaximizeBubbleController::Bubble* bubble)
: bubble_(bubble),
@@ -693,25 +647,19 @@
MaximizeBubbleController::MaximizeBubbleController(
FrameMaximizeButton* frame_maximize_button,
- bool is_maximized,
- int appearance_delay_ms)
+ bool is_maximized)
: frame_maximize_button_(frame_maximize_button),
bubble_(NULL),
- is_maximized_(is_maximized),
- appearance_delay_ms_(appearance_delay_ms) {
+ is_maximized_(is_maximized) {
// Create the task which will create the bubble delayed.
base::OneShotTimer<MaximizeBubbleController>* new_timer =
new base::OneShotTimer<MaximizeBubbleController>();
- // Note: Even if there was no delay time given, we need to have a timer.
new_timer->Start(
FROM_HERE,
- base::TimeDelta::FromMilliseconds(
- appearance_delay_ms_ ? appearance_delay_ms_ : 10),
+ base::TimeDelta::FromMilliseconds(kBubbleAppearanceDelayMS),
this,
&MaximizeBubbleController::CreateBubble);
timer_.reset(new_timer);
- if (!appearance_delay_ms_)
- CreateBubble();
}
MaximizeBubbleController::~MaximizeBubbleController() {
@@ -745,11 +693,6 @@
frame_maximize_button_->SnapButtonHovered(snap_type);
}
-views::CustomButton* MaximizeBubbleController::GetButtonForUnitTest(
- SnapType state) {
- return bubble_ ? bubble_->GetButtonForUnitTest(state) : NULL;
-}
-
void MaximizeBubbleController::RequestDestructionThroughOwner() {
// Tell the parent to destroy us (if this didn't happen yet).
if (timer_.get()) {
@@ -762,7 +705,7 @@
void MaximizeBubbleController::CreateBubble() {
if (!bubble_)
- bubble_ = new Bubble(this, appearance_delay_ms_);
+ bubble_ = new Bubble(this);
timer_->Stop();
}
@@ -797,20 +740,4 @@
views::ImageButton::OnMouseExited(event);
}
-bool BubbleDialogButton::OnMouseDragged(const ui::MouseEvent& event) {
- if (!button_row_->bubble()->controller())
- return false;
-
- // Remove the phantom window when we leave the button.
- gfx::Point screen_location(event.location());
- View::ConvertPointToScreen(this, &screen_location);
- if (!GetBoundsInScreen().Contains(screen_location))
- button_row_->ButtonHovered(NULL);
- else
- button_row_->ButtonHovered(this);
-
- // Pass the event on to the normal handler.
- return views::ImageButton::OnMouseDragged(event);
-}
-
} // namespace ash
« no previous file with comments | « ash/wm/maximize_bubble_controller.h ('k') | ash/wm/workspace/frame_maximize_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698