summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 22:07:49 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-11 22:07:49 +0000
commit82157fb8970ce4bba5c7ec1b4b2a678cb68320c5 (patch)
treece171ead797320ca29e5ca66fd4c5c1fe6c31819 /ash
parentbc21c0c7cb1c227d8887e5b1d17f796e0b3ddacd (diff)
downloadchromium_src-82157fb8970ce4bba5c7ec1b4b2a678cb68320c5.zip
chromium_src-82157fb8970ce4bba5c7ec1b4b2a678cb68320c5.tar.gz
chromium_src-82157fb8970ce4bba5c7ec1b4b2a678cb68320c5.tar.bz2
ash: Some more code-cleanup related to the tray.
BUG=122295 TEST=existing tests Review URL: https://chromiumcodereview.appspot.com/10049003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131852 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/focus_cycler_unittest.cc18
-rw-r--r--ash/status_area/status_area_view.cc30
-rw-r--r--ash/status_area/status_area_view.h3
-rw-r--r--ash/wm/shelf_layout_manager_unittest.cc7
4 files changed, 22 insertions, 36 deletions
diff --git a/ash/focus_cycler_unittest.cc b/ash/focus_cycler_unittest.cc
index 7a5bec9..23468f3 100644
--- a/ash/focus_cycler_unittest.cc
+++ b/ash/focus_cycler_unittest.cc
@@ -27,7 +27,7 @@ namespace {
internal::StatusAreaView* GetStatusAreaView(views::Widget* widget) {
return static_cast<internal::StatusAreaView*>(
- widget->GetContentsView()->child_at(0));
+ widget->GetContentsView());
}
} // namespace
@@ -60,10 +60,6 @@ TEST_F(FocusCyclerTest, CycleFocusForward) {
GetStatusAreaView(status_widget)->SetFocusCyclerForTesting(
focus_cycler.get());
- // Add a mock button to the status area.
- status_widget->GetContentsView()->AddChildView(
- new views::MenuButton(NULL, string16(), NULL, false));
-
// Add the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
ASSERT_TRUE(launcher);
@@ -102,10 +98,6 @@ TEST_F(FocusCyclerTest, CycleFocusBackward) {
GetStatusAreaView(status_widget)->SetFocusCyclerForTesting(
focus_cycler.get());
- // Add a mock button to the status area.
- status_widget->GetContentsView()->AddChildView(
- new views::MenuButton(NULL, string16(), NULL, false));
-
// Add the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
ASSERT_TRUE(launcher);
@@ -175,10 +167,6 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusForwardInvisible) {
GetStatusAreaView(status_widget)->SetFocusCyclerForTesting(
focus_cycler.get());
- // Add a mock button to the status area.
- status_widget->GetContentsView()->AddChildView(
- new views::MenuButton(NULL, string16(), NULL, false));
-
// Add the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
ASSERT_TRUE(launcher);
@@ -213,10 +201,6 @@ TEST_F(FocusCyclerLauncherTest, CycleFocusBackwardInvisible) {
GetStatusAreaView(status_widget)->SetFocusCyclerForTesting(
focus_cycler.get());
- // Add a mock button to the status area.
- status_widget->GetContentsView()->AddChildView(
- new views::MenuButton(NULL, string16(), NULL, false));
-
// Add the launcher
Launcher* launcher = Shell::GetInstance()->launcher();
ASSERT_TRUE(launcher);
diff --git a/ash/status_area/status_area_view.cc b/ash/status_area/status_area_view.cc
index 3804cb7..7e1478f 100644
--- a/ash/status_area/status_area_view.cc
+++ b/ash/status_area/status_area_view.cc
@@ -23,6 +23,7 @@ namespace internal {
StatusAreaView::StatusAreaView()
: focus_cycler_for_testing_(NULL) {
+ SetLayoutManager(new views::FillLayout);
}
StatusAreaView::~StatusAreaView() {
@@ -32,6 +33,10 @@ void StatusAreaView::SetFocusCyclerForTesting(const FocusCycler* focus_cycler) {
focus_cycler_for_testing_ = focus_cycler;
}
+views::View* StatusAreaView::GetDefaultFocusableChild() {
+ return child_at(0);
+}
+
bool StatusAreaView::AcceleratorPressed(const ui::Accelerator& accelerator) {
if (accelerator.key_code() == ui::VKEY_ESCAPE) {
RemovePaneFocus();
@@ -58,38 +63,27 @@ bool StatusAreaView::CanActivate() const {
}
void StatusAreaView::DeleteDelegate() {
- // If this is used as the content-view of the widget, then do nothing, since
- // deleting the widget will end up deleting this. But if this is used only as
- // the widget-delegate, then delete this now.
- if (!GetWidget())
- delete this;
}
ASH_EXPORT views::Widget* CreateStatusArea(views::View* contents) {
+ if (!contents) {
+ contents = new views::View;
+ contents->set_focusable(true);
+ }
StatusAreaView* status_area_view = new StatusAreaView;
- if (!contents)
- contents = status_area_view;
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
- gfx::Size ps = contents ? contents->GetPreferredSize() : gfx::Size(200, 29);
+ gfx::Size ps = contents->GetPreferredSize();
params.bounds = gfx::Rect(0, 0, ps.width(), ps.height());
params.delegate = status_area_view;
params.parent = Shell::GetInstance()->GetContainer(
ash::internal::kShellWindowId_StatusContainer);
params.transparent = true;
widget->Init(params);
- // TODO(sky): We need the contents to be an AccessiblePaneView for
- // FocusCycler. SystemTray isn't an AccessiblePaneView, so we wrap it in
- // one. This is a bit of a hack, but at this point this code path is only used
- // for tests. Once the migration to SystemTray is done this method should no
- // longer be needed and we can nuke this.
- views::AccessiblePaneView* accessible_pane =
- new views::AccessiblePaneView;
- accessible_pane->SetLayoutManager(new views::FillLayout);
- accessible_pane->AddChildView(contents);
widget->set_focus_on_creation(false);
- widget->SetContentsView(accessible_pane);
+ status_area_view->AddChildView(contents);
+ widget->SetContentsView(status_area_view);
widget->Show();
widget->GetNativeView()->SetName("StatusAreaView");
return widget;
diff --git a/ash/status_area/status_area_view.h b/ash/status_area/status_area_view.h
index 3738da1..9046573 100644
--- a/ash/status_area/status_area_view.h
+++ b/ash/status_area/status_area_view.h
@@ -25,6 +25,9 @@ class ASH_EXPORT StatusAreaView : public views::WidgetDelegate,
// Sets the focus cycler.
void SetFocusCyclerForTesting(const FocusCycler* focus_cycler);
+ // Overridden from views::AccessiblePaneView.
+ virtual View* GetDefaultFocusableChild() OVERRIDE;
+
// Overridden from views::View:
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
virtual views::Widget* GetWidget() OVERRIDE;
diff --git a/ash/wm/shelf_layout_manager_unittest.cc b/ash/wm/shelf_layout_manager_unittest.cc
index 7ab0637..3813e2e 100644
--- a/ash/wm/shelf_layout_manager_unittest.cc
+++ b/ash/wm/shelf_layout_manager_unittest.cc
@@ -333,7 +333,7 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
}
// Verifies the shelf is visible when status/launcher is focused.
-TEST_F(ShelfLayoutManagerTest, VisibileWhenStatusOrLauncherFocused) {
+TEST_F(ShelfLayoutManagerTest, VisibleWhenStatusOrLauncherFocused) {
// Since ShelfLayoutManager queries for mouse location, move the mouse so
// it isn't over the shelf.
aura::test::EventGenerator generator(
@@ -359,7 +359,12 @@ TEST_F(ShelfLayoutManagerTest, VisibileWhenStatusOrLauncherFocused) {
widget->Activate();
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+ // Trying to activate the status should fail, since we only allow activating
+ // it when the user is using the keyboard (i.e. through FocusCycler).
shelf->status()->Activate();
+ EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
+
+ shelf->launcher()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
EXPECT_EQ(ShelfLayoutManager::AUTO_HIDE_SHOWN, shelf->auto_hide_state());
}