#include "ui/compositor/test/test_layers.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
-#include "ui/events/gestures/gesture_configuration.h"
+#include "ui/events/gesture_detection/gesture_configuration.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/canvas.h"
WindowTest() : max_separation_(0) {
}
- virtual void SetUp() OVERRIDE {
+ void SetUp() override {
AuraTestBase::SetUp();
// TODO: there needs to be an easier way to do this.
- max_separation_ = ui::GestureConfiguration::
- max_separation_for_gesture_touches_in_pixels();
- ui::GestureConfiguration::
- set_max_separation_for_gesture_touches_in_pixels(0);
+ max_separation_ = ui::GestureConfiguration::GetInstance()
+ ->max_separation_for_gesture_touches_in_pixels();
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_separation_for_gesture_touches_in_pixels(0);
}
- virtual void TearDown() OVERRIDE {
+ void TearDown() override {
AuraTestBase::TearDown();
- ui::GestureConfiguration::
- set_max_separation_for_gesture_touches_in_pixels(max_separation_);
+ ui::GestureConfiguration::GetInstance()
+ ->set_max_separation_for_gesture_touches_in_pixels(max_separation_);
}
private:
- int max_separation_;
+ float max_separation_;
DISALLOW_COPY_AND_ASSIGN(WindowTest);
};
bool in_destroying() const { return in_destroying_; }
- virtual void OnWindowDestroying(Window* window) OVERRIDE {
+ void OnWindowDestroying(Window* window) override {
EXPECT_FALSE(in_destroying_);
in_destroying_ = true;
destroying_count_++;
}
- virtual void OnWindowDestroyed(Window* window) OVERRIDE {
+ void OnWindowDestroyed(Window* window) override {
EXPECT_TRUE(in_destroying_);
in_destroying_ = false;
destroyed_count_++;
: parent_delegate_(parent_delegate) {
}
- virtual void OnWindowDestroying(Window* window) OVERRIDE {
+ void OnWindowDestroying(Window* window) override {
EXPECT_TRUE(parent_delegate_->in_destroying());
DestroyTrackingDelegateImpl::OnWindowDestroying(window);
}
void set_window(Window* window) { window_ = window; }
- virtual void OnWindowDestroyed(Window* window) OVERRIDE {
+ void OnWindowDestroyed(Window* window) override {
EXPECT_FALSE(window_->parent());
}
int touch_event_count() const { return touch_event_count_; }
int gesture_event_count() const { return gesture_event_count_; }
- virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
+ void OnMouseEvent(ui::MouseEvent* event) override {
if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED)
capture_changed_event_count_++;
mouse_event_count_++;
}
- virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
- touch_event_count_++;
- }
- virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
+ void OnTouchEvent(ui::TouchEvent* event) override { touch_event_count_++; }
+ void OnGestureEvent(ui::GestureEvent* event) override {
gesture_event_count_++;
}
- virtual void OnCaptureLost() OVERRIDE {
- capture_lost_count_++;
- }
+ void OnCaptureLost() override { capture_lost_count_++; }
private:
int capture_changed_event_count_;
public:
GestureTrackPositionDelegate() {}
- virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
+ void OnGestureEvent(ui::GestureEvent* event) override {
position_ = event->location();
event->StopPropagation();
}
public:
SelfEventHandlingWindowDelegate() {}
- virtual bool ShouldDescendIntoChildForEventHandling(
+ bool ShouldDescendIntoChildForEventHandling(
Window* child,
- const gfx::Point& location) OVERRIDE {
+ const gfx::Point& location) override {
return false;
}
DestroyWindowDelegate() {}
private:
- virtual ~DestroyWindowDelegate() {}
+ ~DestroyWindowDelegate() override {}
// Overridden from WindowDelegate.
- virtual void OnWindowDestroyed(Window* window) OVERRIDE {
- delete this;
- }
+ void OnWindowDestroyed(Window* window) override { delete this; }
DISALLOW_COPY_AND_ASSIGN(DestroyWindowDelegate);
};
public:
AddedToRootWindowObserver() : called_(false) {}
- virtual void OnWindowAddedToRootWindow(Window* window) OVERRIDE {
- called_ = true;
- }
+ void OnWindowAddedToRootWindow(Window* window) override { called_ = true; }
bool called() const { return called_; }
public:
MouseEnterExitWindowDelegate() : entered_(false), exited_(false) {}
- virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
+ void OnMouseEvent(ui::MouseEvent* event) override {
switch (event->type()) {
case ui::ET_MOUSE_ENTERED:
EXPECT_TRUE(event->flags() & ui::EF_IS_SYNTHESIZED);
hidden_ = 0;
}
- virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {
+ void OnWindowTargetVisibilityChanged(bool visible) override {
if (visible)
shown_++;
else
struct VisibilityInfo {
bool window_visible;
bool visible_param;
+ int changed_count;
};
WindowObserverTest()
old_property_value_(-3) {
}
- virtual ~WindowObserverTest() {}
+ ~WindowObserverTest() override {}
const VisibilityInfo* GetVisibilityInfo() const {
return visibility_info_.get();
}
private:
- virtual void OnWindowAdded(Window* new_window) OVERRIDE {
- added_count_++;
- }
+ void OnWindowAdded(Window* new_window) override { added_count_++; }
- virtual void OnWillRemoveWindow(Window* window) OVERRIDE {
- removed_count_++;
- }
+ void OnWillRemoveWindow(Window* window) override { removed_count_++; }
- virtual void OnWindowVisibilityChanged(Window* window,
- bool visible) OVERRIDE {
- visibility_info_.reset(new VisibilityInfo);
+ void OnWindowVisibilityChanged(Window* window, bool visible) override {
+ if (!visibility_info_) {
+ visibility_info_.reset(new VisibilityInfo);
+ visibility_info_->changed_count = 0;
+ }
visibility_info_->window_visible = window->IsVisible();
visibility_info_->visible_param = visible;
+ visibility_info_->changed_count++;
}
- virtual void OnWindowDestroyed(Window* window) OVERRIDE {
+ void OnWindowDestroyed(Window* window) override {
EXPECT_FALSE(window->parent());
destroyed_count_++;
}
- virtual void OnWindowPropertyChanged(Window* window,
- const void* key,
- intptr_t old) OVERRIDE {
+ void OnWindowPropertyChanged(Window* window,
+ const void* key,
+ intptr_t old) override {
property_key_ = key;
old_property_value_ = old;
}
- virtual void OnAncestorWindowTransformed(Window* source,
- Window* window) OVERRIDE {
+ void OnAncestorWindowTransformed(Window* source, Window* window) override {
transform_notifications_.push_back(
std::make_pair(source->id(), window->id()));
}
return;
EXPECT_FALSE(GetVisibilityInfo()->window_visible);
EXPECT_FALSE(GetVisibilityInfo()->visible_param);
+ EXPECT_EQ(1, GetVisibilityInfo()->changed_count);
// If parent isn't visible, showing window won't make the window visible, but
// passed visible value must be true.
return;
EXPECT_FALSE(GetVisibilityInfo()->window_visible);
EXPECT_TRUE(GetVisibilityInfo()->visible_param);
+ EXPECT_EQ(1, GetVisibilityInfo()->changed_count);
// If parent is visible, showing window will make the window
// visible and the passed visible value is true.
return;
EXPECT_TRUE(GetVisibilityInfo()->window_visible);
EXPECT_TRUE(GetVisibilityInfo()->visible_param);
+ EXPECT_EQ(1, GetVisibilityInfo()->changed_count);
+
+ // Verify that the OnWindowVisibilityChanged only once
+ // per visibility change.
+ w2->Hide();
+ EXPECT_EQ(2, GetVisibilityInfo()->changed_count);
+
+ w2->Hide();
+ EXPECT_EQ(2, GetVisibilityInfo()->changed_count);
}
// Test if OnWindowDestroyed is invoked as expected.
: ignore_visibility_changes_(false) {
client::SetVisibilityClient(root_window, this);
}
- virtual ~TestVisibilityClient() {
- }
+ ~TestVisibilityClient() override {}
void set_ignore_visibility_changes(bool ignore_visibility_changes) {
ignore_visibility_changes_ = ignore_visibility_changes;
}
// Overridden from client::VisibilityClient:
- virtual void UpdateLayerVisibility(aura::Window* window,
- bool visible) OVERRIDE {
+ void UpdateLayerVisibility(aura::Window* window, bool visible) override {
if (!ignore_visibility_changes_)
window->layer()->SetVisible(visible);
}
class RootWindowAttachmentObserver : public WindowObserver {
public:
RootWindowAttachmentObserver() : added_count_(0), removed_count_(0) {}
- virtual ~RootWindowAttachmentObserver() {}
+ ~RootWindowAttachmentObserver() override {}
int added_count() const { return added_count_; }
int removed_count() const { return removed_count_; }
}
// Overridden from WindowObserver:
- virtual void OnWindowAddedToRootWindow(Window* window) OVERRIDE {
- ++added_count_;
- }
- virtual void OnWindowRemovingFromRootWindow(Window* window,
- Window* new_root) OVERRIDE {
+ void OnWindowAddedToRootWindow(Window* window) override { ++added_count_; }
+ void OnWindowRemovingFromRootWindow(Window* window,
+ Window* new_root) override {
++removed_count_;
}
public:
BoundsChangedWindowObserver() : root_set_(false) {}
- virtual void OnWindowBoundsChanged(Window* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) OVERRIDE {
+ void OnWindowBoundsChanged(Window* window,
+ const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override {
root_set_ = window->GetRootWindow() != NULL;
}
owned_window_.reset(window);
}
- virtual void OnWindowDestroyed(Window* window) OVERRIDE {
- owned_window_.reset(NULL);
- }
+ void OnWindowDestroyed(Window* window) override { owned_window_.reset(NULL); }
private:
scoped_ptr<Window> owned_window_;
}
// Window
- virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) OVERRIDE {
+ void OnBoundsChanged(const gfx::Rect& old_bounds,
+ const gfx::Rect& new_bounds) override {
bounds_changed_ = true;
}
}
// WindowObserver overrides:
- virtual void OnWindowAddedToRootWindow(Window* window) OVERRIDE {
- added_count_++;
- }
- virtual void OnWindowRemovingFromRootWindow(Window* window,
- Window* new_root) OVERRIDE {
+ void OnWindowAddedToRootWindow(Window* window) override { added_count_++; }
+ void OnWindowRemovingFromRootWindow(Window* window,
+ Window* new_root) override {
removed_count_++;
}
HierarchyObserver(Window* target) : target_(target) {
target_->AddObserver(this);
}
- virtual ~HierarchyObserver() {
- target_->RemoveObserver(this);
- }
+ ~HierarchyObserver() override { target_->RemoveObserver(this); }
void ValidateState(
int index,
private:
// Overridden from WindowObserver:
- virtual void OnWindowHierarchyChanging(
- const HierarchyChangeParams& params) OVERRIDE {
+ void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override {
params_.push_back(params);
}
- virtual void OnWindowHierarchyChanged(
- const HierarchyChangeParams& params) OVERRIDE {
+ void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override {
params_.push_back(params);
}
class PaintWindowDelegate : public TestWindowDelegate {
public:
PaintWindowDelegate() : paint_count_(0) {}
- virtual ~PaintWindowDelegate() {}
+ ~PaintWindowDelegate() override {}
const gfx::Rect& most_recent_paint_clip_bounds() const {
return most_recent_paint_clip_bounds_;
int paint_count() const { return paint_count_; }
// TestWindowDelegate::
- virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
+ void OnPaint(gfx::Canvas* canvas) override {
paint_count_++;
canvas->GetClipBounds(&most_recent_paint_clip_bounds_);
const SkMatrix& matrix = canvas->sk_canvas()->getTotalMatrix();
"21 11 12",
},
};
- for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) {
+ for (size_t i = 0; i < arraysize(data); ++i) {
test::TestWindowDelegate delegate;
Window root(NULL);
root.Init(WINDOW_LAYER_NOT_DRAWN);
TestLayerAnimationObserver()
: animation_completed_(false),
animation_aborted_(false) {}
- virtual ~TestLayerAnimationObserver() {}
+ ~TestLayerAnimationObserver() override {}
bool animation_completed() const { return animation_completed_; }
bool animation_aborted() const { return animation_aborted_; }
private:
// ui::LayerAnimationObserver:
- virtual void OnLayerAnimationEnded(
- ui::LayerAnimationSequence* sequence) OVERRIDE {
+ void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override {
animation_completed_ = true;
}
- virtual void OnLayerAnimationAborted(
- ui::LayerAnimationSequence* sequence) OVERRIDE {
+ void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override {
animation_aborted_ = true;
}
- virtual void OnLayerAnimationScheduled(
- ui::LayerAnimationSequence* sequence) OVERRIDE {
- }
+ void OnLayerAnimationScheduled(
+ ui::LayerAnimationSequence* sequence) override {}
bool animation_completed_;
bool animation_aborted_;