chromeos: Use Screen::GetDisplayForNewWindows in chrome/browser
display::Screen (and ScreenMus) now has the display for new windows,
so we can use that when making new browser windows under both mash
and classic ash. Likewise, we can use display::Screen (as ScreenAsh)
for new windows inside of ash.
This lets me remove ShellStateClient, a different mechanism that
accomplishes the same goal in a less general way.
Leave ash::ShellState for now. I will clean that up in a separate CL.
[email protected]
Bug: 764009
Test: existing browser_tests for browser frame/size
Change-Id: I5c255dc2bf8fdd48f519f148d29aca3d37e7ae73
Reviewed-on: https://chromium-review.googlesource.com/1168197
Reviewed-by: James Cook <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Commit-Queue: James Cook <[email protected]>
Cr-Commit-Position: refs/heads/master@{#582336}
diff --git a/ash/shell_state_unittest.cc b/ash/shell_state_unittest.cc
index 7fd10957..b3a65f1a 100644
--- a/ash/shell_state_unittest.cc
+++ b/ash/shell_state_unittest.cc
@@ -6,61 +6,29 @@
#include <stdint.h>
-#include "ash/public/interfaces/shell_state.mojom.h"
#include "ash/scoped_root_window_for_new_windows.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
-#include "base/macros.h"
-#include "mojo/public/cpp/bindings/binding.h"
+#include "ui/display/display.h"
#include "ui/display/manager/display_manager.h"
+#include "ui/display/screen.h"
namespace ash {
namespace {
-// Simulates the client interface in chrome.
-class TestShellStateClient : public mojom::ShellStateClient {
- public:
- TestShellStateClient() = default;
- ~TestShellStateClient() override = default;
-
- mojom::ShellStateClientPtr CreateInterfacePtrAndBind() {
- mojom::ShellStateClientPtr ptr;
- binding_.Bind(mojo::MakeRequest(&ptr));
- return ptr;
- }
-
- // mojom::ShellStateClient:
- void SetDisplayIdForNewWindows(int64_t display_id) override {
- last_display_id_ = display_id;
- }
-
- int64_t last_display_id_ = 0;
-
- private:
- mojo::Binding<mojom::ShellStateClient> binding_{this};
-
- DISALLOW_COPY_AND_ASSIGN(TestShellStateClient);
-};
-
using ShellStateTest = AshTestBase;
-TEST_F(ShellStateTest, Basics) {
+TEST_F(ShellStateTest, GetDisplayForNewWindows) {
UpdateDisplay("1024x768,800x600");
const int64_t primary_display_id = display_manager()->GetDisplayAt(0).id();
const int64_t secondary_display_id = display_manager()->GetDisplayAt(1).id();
- ShellState* shell_state = Shell::Get()->shell_state();
- TestShellStateClient client;
-
- // Adding a client notifies it with the initial display id.
- shell_state->AddClient(client.CreateInterfacePtrAndBind());
- shell_state->FlushMojoForTest();
- EXPECT_EQ(primary_display_id, client.last_display_id_);
+ display::Screen* screen = display::Screen::GetScreen();
+ EXPECT_EQ(primary_display_id, screen->GetDisplayForNewWindows().id());
// Setting a root window for new windows notifies the client.
ScopedRootWindowForNewWindows scoped_root(Shell::GetAllRootWindows()[1]);
- shell_state->FlushMojoForTest();
- EXPECT_EQ(secondary_display_id, client.last_display_id_);
+ EXPECT_EQ(secondary_display_id, screen->GetDisplayForNewWindows().id());
}
} // namespace