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

Unified Diff: ash/common/test/ash_test.h

Issue 2374893002: Adds AshTest (Closed)
Patch Set: cleanup Created 4 years, 3 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
Index: ash/common/test/ash_test.h
diff --git a/ash/common/test/ash_test.h b/ash/common/test/ash_test.h
new file mode 100644
index 0000000000000000000000000000000000000000..4e55c7b923531e1761b914f52f8f86b85c265113
--- /dev/null
+++ b/ash/common/test/ash_test.h
@@ -0,0 +1,99 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_COMMON_TEST_ASH_TEST_H_
+#define ASH_COMMON_TEST_ASH_TEST_H_
+
+#include <memory>
+#include <string>
+
+#include "ash/common/shell_window_ids.h"
+#include "base/macros.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/display/manager/display_layout.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/views/widget/widget.h"
+#include "ui/wm/public/window_types.h"
+
+namespace display {
+class Display;
+}
+
+namespace ash {
+
+class AshTestImpl;
+class WmWindow;
+
+// Wraps a WmWindow calling WmWindow::Destroy() from the destructor.
James Cook 2016/09/28 01:19:42 nit: Can you add another line or two here explaini
sky 2016/09/28 17:31:45 Done.
+class WindowOwner {
+ public:
+ explicit WindowOwner(WmWindow* window);
+ ~WindowOwner();
+
+ WmWindow* window() { return window_; }
+
+ private:
+ WmWindow* window_;
+
+ DISALLOW_COPY_AND_ASSIGN(WindowOwner);
+};
+
+// Base class for ash tests. This class calls through to AshTestImpl for the
+// real implementation. This class exists so that tests can be written to
+// ash/common and run in both mus and aura.
+//
+// The implementation of AshTestImpl that is used depends upon gn targets. To
+// use the aura backend depend on "//ash:ash_with_aura_test_support." The mus
+// backend is not provided as a separate link target.
James Cook 2016/09/28 01:19:42 For my knowledge: Is that because mash_unittests w
sky 2016/09/28 17:31:45 The only place that needs the mus implementation i
+class AshTest : public testing::Test {
+ public:
+ AshTest();
+ ~AshTest() override;
+
+ bool SupportsMultipleDisplays() const;
+
+ // Update the display configuration as given in |display_spec|.
+ // See test::DisplayManagerTestApi::UpdateDisplay for more details.
+ void UpdateDisplay(const std::string& display_spec);
+
+ // Creates a top level visible window in the appropriate container. If
+ // |bounds_is_screen| is empty the window is added to the primary root window,
James Cook 2016/09/28 01:19:42 nit: bounds_in_screen
sky 2016/09/28 17:31:45 Done.
+ // otherwise the window is added to the display matching |bounds_in_screen|.
+ // |shell_window_id| is the shell window id to give to the new window.
+ std::unique_ptr<WindowOwner> CreateTestWindow(
+ const gfx::Rect& bounds_in_screen = gfx::Rect(),
+ ui::wm::WindowType type = ui::wm::WINDOW_TYPE_NORMAL,
+ int shell_window_id = kShellWindowId_Invalid);
+
+ // Returns the Display for the secondary display. It's assumed there is two
James Cook 2016/09/28 01:19:42 super nit: "there is" -> "there are"
sky 2016/09/28 17:31:45 Done.
+ // displays.
+ display::Display GetSecondaryDisplay();
+
+ // Sets the placement of the secondary display. Returns true if the secondary
+ // display can be moved, false otherwise. The false return value is temporary
+ // until mus fully supports this.
+ bool SetSecondaryDisplayPlacement(
+ display::DisplayPlacement::Position position,
+ int offset);
+
+ // Configures |init_params| so that the resulting Widget will appear on the
+ // display |window| is on.
+ void ConfigureWidgetInitParamsForDisplay(
James Cook 2016/09/28 01:19:42 It seems a little odd that this doesn't take a Dis
sky 2016/09/28 17:31:45 I'll need it shortly, but I can push it to the pat
+ WmWindow* window,
+ views::Widget::InitParams* init_params);
+
+ protected:
+ // testing::Test:
+ void SetUp() override;
+ void TearDown() override;
+
+ private:
+ std::unique_ptr<AshTestImpl> test_impl_;
+
+ DISALLOW_COPY_AND_ASSIGN(AshTest);
+};
+
+} // namespace ash
+
+#endif // ASH_COMMON_TEST_ASH_TEST_H_
« no previous file with comments | « ash/BUILD.gn ('k') | ash/common/test/ash_test.cc » ('j') | ash/common/test/ash_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698