Commit e87cbf96 authored by sky's avatar sky Committed by Commit bot

chromeos: Converts more tests to AshTestBase

BUG=707057
TEST=test only changes
R=jamescook@chromium.org

Review-Url: https://codereview.chromium.org/2852493002
Cr-Commit-Position: refs/heads/master@{#467811}
parent 9c0e322c
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/tray/system_tray_delegate.h" #include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_item.h" #include "ash/system/tray/system_tray_item.h"
#include "ash/test/ash_test.h" #include "ash/test/ash_test_base.h"
#include "ash/wm/maximize_mode/maximize_mode_controller.h" #include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "ui/views/view.h" #include "ui/views/view.h"
namespace ash { namespace ash {
class TrayBrightnessTest : public AshTest { class TrayBrightnessTest : public test::AshTestBase {
public: public:
TrayBrightnessTest() {} TrayBrightnessTest() {}
~TrayBrightnessTest() override {} ~TrayBrightnessTest() override {}
......
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
#include "ash/system/date/date_view.h" #include "ash/system/date/date_view.h"
#include "ash/test/ash_test.h" #include "ash/test/ash_test_base.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
namespace ash { namespace ash {
namespace tray { namespace tray {
class TimeViewTest : public AshTest { class TimeViewTest : public test::AshTestBase {
public: public:
TimeViewTest() {} TimeViewTest() {}
~TimeViewTest() override {} ~TimeViewTest() override {}
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "ash/system/tray/system_tray.h" #include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_notifier.h" #include "ash/system/tray/system_tray_notifier.h"
#include "ash/system/tray/tray_item_view.h" #include "ash/system/tray/tray_item_view.h"
#include "ash/test/ash_test.h" #include "ash/test/ash_test_base.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -36,7 +36,7 @@ void ClickViewCenter(views::View* view) { ...@@ -36,7 +36,7 @@ void ClickViewCenter(views::View* view) {
ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE)); ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE));
} }
class ScreenTrayItemTest : public AshTest { class ScreenTrayItemTest : public test::AshTestBase {
public: public:
ScreenTrayItemTest() : tray_item_(NULL), stop_callback_hit_count_(0) {} ScreenTrayItemTest() : tray_item_(NULL), stop_callback_hit_count_(0) {}
~ScreenTrayItemTest() override {} ~ScreenTrayItemTest() override {}
...@@ -47,7 +47,7 @@ class ScreenTrayItemTest : public AshTest { ...@@ -47,7 +47,7 @@ class ScreenTrayItemTest : public AshTest {
int stop_callback_hit_count() const { return stop_callback_hit_count_; } int stop_callback_hit_count() const { return stop_callback_hit_count_; }
void SetUp() override { void SetUp() override {
AshTest::SetUp(); AshTestBase::SetUp();
TrayItemView::DisableAnimationsForTest(); TrayItemView::DisableAnimationsForTest();
} }
...@@ -192,7 +192,7 @@ void TestSystemTrayInteraction(ScreenTrayItemTest* test) { ...@@ -192,7 +192,7 @@ void TestSystemTrayInteraction(ScreenTrayItemTest* test) {
EXPECT_FALSE(tray_item->tray_view()->visible()); EXPECT_FALSE(tray_item->tray_view()->visible());
std::vector<SystemTrayItem*> tray_items = std::vector<SystemTrayItem*> tray_items =
AshTest::GetPrimarySystemTray()->GetTrayItems(); test::AshTestBase::GetPrimarySystemTray()->GetTrayItems();
EXPECT_NE(std::find(tray_items.begin(), tray_items.end(), tray_item), EXPECT_NE(std::find(tray_items.begin(), tray_items.end(), tray_item),
tray_items.end()); tray_items.end());
...@@ -200,16 +200,16 @@ void TestSystemTrayInteraction(ScreenTrayItemTest* test) { ...@@ -200,16 +200,16 @@ void TestSystemTrayInteraction(ScreenTrayItemTest* test) {
EXPECT_TRUE(tray_item->tray_view()->visible()); EXPECT_TRUE(tray_item->tray_view()->visible());
// The default view should be created in a new bubble. // The default view should be created in a new bubble.
AshTest::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); test::AshTestBase::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
EXPECT_TRUE(tray_item->default_view()); EXPECT_TRUE(tray_item->default_view());
AshTest::GetPrimarySystemTray()->CloseSystemBubble(); test::AshTestBase::GetPrimarySystemTray()->CloseSystemBubble();
EXPECT_FALSE(tray_item->default_view()); EXPECT_FALSE(tray_item->default_view());
test->StopSession(); test->StopSession();
EXPECT_FALSE(tray_item->tray_view()->visible()); EXPECT_FALSE(tray_item->tray_view()->visible());
// The default view should not be visible because session is stopped. // The default view should not be visible because session is stopped.
AshTest::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); test::AshTestBase::GetPrimarySystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
EXPECT_FALSE(tray_item->default_view()->visible()); EXPECT_FALSE(tray_item->default_view()->visible());
} }
......
...@@ -6,20 +6,22 @@ ...@@ -6,20 +6,22 @@
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test.h" #include "ash/test/ash_test_base.h"
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/window_state_aura.h"
#include "ash/wm/window_util.h"
#include "ash/wm_window.h" #include "ash/wm_window.h"
#include "ui/base/hit_test.h" #include "ui/base/hit_test.h"
namespace ash { namespace ash {
class MruWindowTrackerTest : public AshTest { class MruWindowTrackerTest : public test::AshTestBase {
public: public:
MruWindowTrackerTest() {} MruWindowTrackerTest() {}
~MruWindowTrackerTest() override {} ~MruWindowTrackerTest() override {}
std::unique_ptr<WindowOwner> CreateTestWindow() { std::unique_ptr<aura::Window> CreateTestWindow() {
return AshTest::CreateTestWindow(gfx::Rect(0, 0, 400, 400)); return AshTestBase::CreateTestWindow(gfx::Rect(0, 0, 400, 400));
} }
MruWindowTracker* mru_window_tracker() { MruWindowTracker* mru_window_tracker() {
...@@ -32,75 +34,66 @@ class MruWindowTrackerTest : public AshTest { ...@@ -32,75 +34,66 @@ class MruWindowTrackerTest : public AshTest {
// Basic test that the activation order is tracked. // Basic test that the activation order is tracked.
TEST_F(MruWindowTrackerTest, Basic) { TEST_F(MruWindowTrackerTest, Basic) {
std::unique_ptr<WindowOwner> w1_owner(CreateTestWindow()); std::unique_ptr<aura::Window> w1(CreateTestWindow());
WmWindow* w1 = w1_owner->window(); std::unique_ptr<aura::Window> w2(CreateTestWindow());
std::unique_ptr<WindowOwner> w2_owner(CreateTestWindow()); std::unique_ptr<aura::Window> w3(CreateTestWindow());
WmWindow* w2 = w2_owner->window(); wm::ActivateWindow(w3.get());
std::unique_ptr<WindowOwner> w3_owner(CreateTestWindow()); wm::ActivateWindow(w2.get());
WmWindow* w3 = w3_owner->window(); wm::ActivateWindow(w1.get());
w3->Activate();
w2->Activate();
w1->Activate();
WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList();
ASSERT_EQ(3u, window_list.size()); ASSERT_EQ(3u, window_list.size());
EXPECT_EQ(w1, window_list[0]); EXPECT_EQ(w1.get(), window_list[0]->aura_window());
EXPECT_EQ(w2, window_list[1]); EXPECT_EQ(w2.get(), window_list[1]->aura_window());
EXPECT_EQ(w3, window_list[2]); EXPECT_EQ(w3.get(), window_list[2]->aura_window());
} }
// Test that minimized windows are not treated specially. // Test that minimized windows are not treated specially.
TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) { TEST_F(MruWindowTrackerTest, MinimizedWindowsAreLru) {
std::unique_ptr<WindowOwner> w1_owner(CreateTestWindow()); std::unique_ptr<aura::Window> w1(CreateTestWindow());
WmWindow* w1 = w1_owner->window(); std::unique_ptr<aura::Window> w2(CreateTestWindow());
std::unique_ptr<WindowOwner> w2_owner(CreateTestWindow()); std::unique_ptr<aura::Window> w3(CreateTestWindow());
WmWindow* w2 = w2_owner->window(); std::unique_ptr<aura::Window> w4(CreateTestWindow());
std::unique_ptr<WindowOwner> w3_owner(CreateTestWindow()); std::unique_ptr<aura::Window> w5(CreateTestWindow());
WmWindow* w3 = w3_owner->window(); std::unique_ptr<aura::Window> w6(CreateTestWindow());
std::unique_ptr<WindowOwner> w4_owner(CreateTestWindow()); wm::ActivateWindow(w6.get());
WmWindow* w4 = w4_owner->window(); wm::ActivateWindow(w5.get());
std::unique_ptr<WindowOwner> w5_owner(CreateTestWindow()); wm::ActivateWindow(w4.get());
WmWindow* w5 = w5_owner->window(); wm::ActivateWindow(w3.get());
std::unique_ptr<WindowOwner> w6_owner(CreateTestWindow()); wm::ActivateWindow(w2.get());
WmWindow* w6 = w6_owner->window(); wm::ActivateWindow(w1.get());
w6->Activate();
w5->Activate(); wm::GetWindowState(w1.get())->Minimize();
w4->Activate(); wm::GetWindowState(w4.get())->Minimize();
w3->Activate(); wm::GetWindowState(w5.get())->Minimize();
w2->Activate();
w1->Activate();
w1->GetWindowState()->Minimize();
w4->GetWindowState()->Minimize();
w5->GetWindowState()->Minimize();
// By minimizing the first window, we activate w2 which will move it to the // By minimizing the first window, we activate w2 which will move it to the
// front of the MRU queue. // front of the MRU queue.
EXPECT_TRUE(w2->IsActive()); EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList(); WmWindow::Windows window_list = mru_window_tracker()->BuildMruWindowList();
EXPECT_EQ(w2, window_list[0]); EXPECT_EQ(w2.get(), window_list[0]->aura_window());
EXPECT_EQ(w1, window_list[1]); EXPECT_EQ(w1.get(), window_list[1]->aura_window());
EXPECT_EQ(w3, window_list[2]); EXPECT_EQ(w3.get(), window_list[2]->aura_window());
EXPECT_EQ(w4, window_list[3]); EXPECT_EQ(w4.get(), window_list[3]->aura_window());
EXPECT_EQ(w5, window_list[4]); EXPECT_EQ(w5.get(), window_list[4]->aura_window());
EXPECT_EQ(w6, window_list[5]); EXPECT_EQ(w6.get(), window_list[5]->aura_window());
} }
// Tests that windows being dragged are only in the WindowList once. // Tests that windows being dragged are only in the WindowList once.
TEST_F(MruWindowTrackerTest, DraggedWindowsInListOnlyOnce) { TEST_F(MruWindowTrackerTest, DraggedWindowsInListOnlyOnce) {
std::unique_ptr<WindowOwner> w1_owner(CreateTestWindow()); std::unique_ptr<aura::Window> w1(CreateTestWindow());
WmWindow* w1 = w1_owner->window(); wm::ActivateWindow(w1.get());
w1->Activate();
// Start dragging the window. // Start dragging the window.
w1->GetWindowState()->CreateDragDetails( wm::GetWindowState(w1.get())->CreateDragDetails(
gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH); gfx::Point(), HTRIGHT, aura::client::WINDOW_MOVE_SOURCE_TOUCH);
// The dragged window should only be in the list once. // The dragged window should only be in the list once.
WmWindow::Windows window_list = WmWindow::Windows window_list =
mru_window_tracker()->BuildWindowListIgnoreModal(); mru_window_tracker()->BuildWindowListIgnoreModal();
EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(), w1)); EXPECT_EQ(1, std::count(window_list.begin(), window_list.end(),
WmWindow::Get(w1.get())));
} }
} // namespace ash } // namespace ash
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