| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" | 5 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 10 #include "ash/shelf/shelf_layout_manager.h" | 10 #include "ash/shelf/shelf_layout_manager.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); | 163 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); |
| 164 int baseline = alignment_delegate()->GetBaseLine(); | 164 int baseline = alignment_delegate()->GetBaseLine(); |
| 165 | 165 |
| 166 scoped_ptr<aura::Window> window( | 166 scoped_ptr<aura::Window> window( |
| 167 CreateTestWindowInShellWithBounds(gfx::Rect(0, 0, 50, 50))); | 167 CreateTestWindowInShellWithBounds(gfx::Rect(0, 0, 50, 50))); |
| 168 aura::Window* docked_container = Shell::GetContainer( | 168 aura::Window* docked_container = Shell::GetContainer( |
| 169 Shell::GetPrimaryRootWindow(), | 169 Shell::GetPrimaryRootWindow(), |
| 170 kShellWindowId_DockedContainer); | 170 kShellWindowId_DockedContainer); |
| 171 docked_container->AddChild(window.get()); | 171 docked_container->AddChild(window.get()); |
| 172 | 172 |
| 173 // Left-side dock should not affect popup alignment | |
| 174 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | 173 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); |
| 175 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | 174 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); |
| 176 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | 175 EXPECT_FALSE(alignment_delegate()->IsTopDown()); |
| 177 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | |
| 178 | |
| 179 // Force dock to right-side | |
| 180 Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, | |
| 181 Shell::GetPrimaryRootWindow()); | |
| 182 Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_BOTTOM, | |
| 183 Shell::GetPrimaryRootWindow()); | |
| 184 | |
| 185 // Right-side dock should not affect popup alignment | |
| 186 EXPECT_EQ(origin_x, alignment_delegate()->GetToastOriginX(toast_size)); | |
| 187 EXPECT_EQ(baseline, alignment_delegate()->GetBaseLine()); | |
| 188 EXPECT_FALSE(alignment_delegate()->IsTopDown()); | |
| 189 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); | 176 EXPECT_FALSE(alignment_delegate()->IsFromLeft()); |
| 190 } | 177 } |
| 191 | 178 |
| 192 TEST_F(AshPopupAlignmentDelegateTest, DisplayResize) { | 179 TEST_F(AshPopupAlignmentDelegateTest, DisplayResize) { |
| 193 const gfx::Rect toast_size(0, 0, 10, 10); | 180 const gfx::Rect toast_size(0, 0, 10, 10); |
| 194 UpdateDisplay("600x600"); | 181 UpdateDisplay("600x600"); |
| 195 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); | 182 int origin_x = alignment_delegate()->GetToastOriginX(toast_size); |
| 196 int baseline = alignment_delegate()->GetBaseLine(); | 183 int baseline = alignment_delegate()->GetBaseLine(); |
| 197 | 184 |
| 198 UpdateDisplay("800x800"); | 185 UpdateDisplay("800x800"); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 SetAlignmentDelegate(scoped_ptr<AshPopupAlignmentDelegate>()); | 240 SetAlignmentDelegate(scoped_ptr<AshPopupAlignmentDelegate>()); |
| 254 | 241 |
| 255 UpdateDisplay("600x600,800x800"); | 242 UpdateDisplay("600x600,800x800"); |
| 256 SetAlignmentDelegate(make_scoped_ptr(new AshPopupAlignmentDelegate())); | 243 SetAlignmentDelegate(make_scoped_ptr(new AshPopupAlignmentDelegate())); |
| 257 | 244 |
| 258 EXPECT_GT(600, | 245 EXPECT_GT(600, |
| 259 alignment_delegate()->GetToastOriginX(gfx::Rect(0, 0, 10, 10))); | 246 alignment_delegate()->GetToastOriginX(gfx::Rect(0, 0, 10, 10))); |
| 260 } | 247 } |
| 261 | 248 |
| 262 } // namespace ash | 249 } // namespace ash |
| OLD | NEW |