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

Unified Diff: ash/system/tray/system_tray_unittest.cc

Issue 10386142: ash: Some code-cleanup around tray-resizing code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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/system/tray/system_tray.cc ('k') | ash/system/tray/tray_item_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/system_tray_unittest.cc
diff --git a/ash/system/tray/system_tray_unittest.cc b/ash/system/tray/system_tray_unittest.cc
index 0946fbd53e114142d24d31accb577ad087552eb8..11c8aca59673ed5153dd04ad14b4bd7b283e8eec 100644
--- a/ash/system/tray/system_tray_unittest.cc
+++ b/ash/system/tray/system_tray_unittest.cc
@@ -8,7 +8,11 @@
#include "ash/system/tray/system_tray_item.h"
#include "ash/test/ash_test_base.h"
+#include "base/utf_string_conversions.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h"
+#include "ui/views/widget/widget.h"
namespace ash {
namespace test {
@@ -29,16 +33,23 @@ class TestItem : public SystemTrayItem {
virtual views::View* CreateTrayView(user::LoginStatus status) {
tray_view_ = new views::View;
+ // Add a label so it has non-zero width.
+ tray_view_->SetLayoutManager(new views::FillLayout);
+ tray_view_->AddChildView(new views::Label(UTF8ToUTF16("Tray")));
return tray_view_;
}
virtual views::View* CreateDefaultView(user::LoginStatus status) {
default_view_ = new views::View;
+ default_view_->SetLayoutManager(new views::FillLayout);
+ default_view_->AddChildView(new views::Label(UTF8ToUTF16("Default")));
return default_view_;
}
virtual views::View* CreateDetailedView(user::LoginStatus status) {
detailed_view_ = new views::View;
+ detailed_view_->SetLayoutManager(new views::FillLayout);
+ detailed_view_->AddChildView(new views::Label(UTF8ToUTF16("Detailed")));
return detailed_view_;
}
@@ -125,6 +136,31 @@ TEST_F(SystemTrayTest, SystemTrayTestItems) {
ASSERT_TRUE(detailed_item->detailed_view() == NULL);
}
+TEST_F(SystemTrayTest, TrayWidgetAutoResizes) {
+ scoped_ptr<SystemTray> tray(CreateSystemTray());
+ ASSERT_TRUE(tray->widget());
+
+ gfx::Size widget_size = tray->widget()->GetWindowScreenBounds().size();
+
+ TestItem* test_item = new TestItem;
+ tray->AddTrayItem(test_item);
+
+ gfx::Size new_size = tray->widget()->GetWindowScreenBounds().size();
+
+ // Adding the new item should change the size of the tray.
+ EXPECT_NE(widget_size.ToString(), new_size.ToString());
+
+ // Hiding the tray view of the new item should also change the size of the
+ // tray.
+ test_item->tray_view()->SetVisible(false);
+ EXPECT_EQ(widget_size.ToString(),
+ tray->widget()->GetWindowScreenBounds().size().ToString());
+
+ test_item->tray_view()->SetVisible(true);
+ EXPECT_EQ(new_size.ToString(),
+ tray->widget()->GetWindowScreenBounds().size().ToString());
+}
+
// Disabled due to a use-after-free, see http://crbug.com/127539.
TEST_F(SystemTrayTest, DISABLED_SystemTrayNotifications) {
scoped_ptr<SystemTray> tray(CreateSystemTray());
« no previous file with comments | « ash/system/tray/system_tray.cc ('k') | ash/system/tray/tray_item_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698