summaryrefslogtreecommitdiffstats
path: root/ash/test
diff options
context:
space:
mode:
Diffstat (limited to 'ash/test')
-rw-r--r--ash/test/aura_shell_test_base.cc37
-rw-r--r--ash/test/aura_shell_test_base.h31
-rw-r--r--ash/test/test_activation_delegate.cc53
-rw-r--r--ash/test/test_activation_delegate.h59
-rw-r--r--ash/test/test_shell_delegate.cc43
-rw-r--r--ash/test/test_shell_delegate.h35
-rw-r--r--ash/test/test_suite.cc52
-rw-r--r--ash/test/test_suite.h28
8 files changed, 338 insertions, 0 deletions
diff --git a/ash/test/aura_shell_test_base.cc b/ash/test/aura_shell_test_base.cc
new file mode 100644
index 0000000..608f76a
--- /dev/null
+++ b/ash/test/aura_shell_test_base.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2011 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.
+
+#include "ash/test/aura_shell_test_base.h"
+
+#include "ash/test/test_shell_delegate.h"
+#include "ui/aura_shell/shell.h"
+
+namespace aura_shell {
+namespace test {
+
+AuraShellTestBase::AuraShellTestBase() {
+}
+
+AuraShellTestBase::~AuraShellTestBase() {
+}
+
+void AuraShellTestBase::SetUp() {
+ aura::test::AuraTestBase::SetUp();
+
+ // Creates Shell and hook with Desktop.
+ aura_shell::Shell::CreateInstance(new TestShellDelegate);
+}
+
+void AuraShellTestBase::TearDown() {
+ // Flush the message loop to finish pending release tasks.
+ RunAllPendingInMessageLoop();
+
+ // Tear down the shell.
+ aura_shell::Shell::DeleteInstance();
+
+ aura::test::AuraTestBase::TearDown();
+}
+
+} // namespace test
+} // namespace aura_shell
diff --git a/ash/test/aura_shell_test_base.h b/ash/test/aura_shell_test_base.h
new file mode 100644
index 0000000..92cb9ca
--- /dev/null
+++ b/ash/test/aura_shell_test_base.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2011 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_TEST_AURA_SHELL_TEST_BASE_H_
+#define ASH_TEST_AURA_SHELL_TEST_BASE_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "ui/aura/test/aura_test_base.h"
+
+namespace aura_shell {
+namespace test {
+
+class AuraShellTestBase : public aura::test::AuraTestBase {
+ public:
+ AuraShellTestBase();
+ virtual ~AuraShellTestBase();
+
+ // testing::Test:
+ virtual void SetUp() OVERRIDE;
+ virtual void TearDown() OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AuraShellTestBase);
+};
+
+} // namespace test
+} // namespace aura_shell
+
+#endif // ASH_TEST_AURA_SHELL_TEST_BASE_H_
diff --git a/ash/test/test_activation_delegate.cc b/ash/test/test_activation_delegate.cc
new file mode 100644
index 0000000..e92223a
--- /dev/null
+++ b/ash/test/test_activation_delegate.cc
@@ -0,0 +1,53 @@
+// Copyright (c) 2011 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.
+
+#include "ash/test/test_activation_delegate.h"
+
+#include "ash/wm/window_util.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/window.h"
+
+namespace aura_shell {
+namespace test {
+
+////////////////////////////////////////////////////////////////////////////////
+// TestActivationDelegate
+
+TestActivationDelegate::TestActivationDelegate()
+ : window_(NULL),
+ window_was_active_(false),
+ activate_(true),
+ activated_count_(0),
+ lost_active_count_(0),
+ should_activate_count_(0) {
+}
+
+TestActivationDelegate::TestActivationDelegate(bool activate)
+ : window_(NULL),
+ window_was_active_(false),
+ activate_(activate),
+ activated_count_(0),
+ lost_active_count_(0),
+ should_activate_count_(0) {
+}
+
+void TestActivationDelegate::SetWindow(aura::Window* window) {
+ window_ = window;
+ aura::client::SetActivationDelegate(window, this);
+}
+
+bool TestActivationDelegate::ShouldActivate(aura::Event* event) {
+ should_activate_count_++;
+ return activate_;
+}
+void TestActivationDelegate::OnActivated() {
+ activated_count_++;
+}
+void TestActivationDelegate::OnLostActive() {
+ if (lost_active_count_++ == 0)
+ window_was_active_ = IsActiveWindow(window_);
+}
+
+} // namespace test
+} // namespace aura_shell
diff --git a/ash/test/test_activation_delegate.h b/ash/test/test_activation_delegate.h
new file mode 100644
index 0000000..d799745
--- /dev/null
+++ b/ash/test/test_activation_delegate.h
@@ -0,0 +1,59 @@
+// Copyright (c) 2011 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_TEST_TEST_ACTIVATION_DELEGATE_H_
+#define ASH_TEST_TEST_ACTIVATION_DELEGATE_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/logging.h"
+#include "ui/aura/client/activation_delegate.h"
+
+namespace aura {
+class Window;
+}
+
+namespace aura_shell {
+namespace test {
+
+// A test ActivationDelegate that can be used to track activation changes for
+// an aura::Window.
+class TestActivationDelegate : public aura::client::ActivationDelegate {
+ public:
+ TestActivationDelegate();
+ explicit TestActivationDelegate(bool activate);
+
+ // Associates this delegate with a Window.
+ void SetWindow(aura::Window* window);
+
+ bool window_was_active() const { return window_was_active_; }
+ void set_activate(bool v) { activate_ = v; }
+ int activated_count() const { return activated_count_; }
+ int lost_active_count() const { return lost_active_count_; }
+ int should_activate_count() const { return should_activate_count_; }
+ void Clear() {
+ activated_count_ = lost_active_count_ = should_activate_count_ = 0;
+ window_was_active_ = false;
+ }
+
+ // Overridden from client::ActivationDelegate:
+ virtual bool ShouldActivate(aura::Event* event) OVERRIDE;
+ virtual void OnActivated() OVERRIDE;
+ virtual void OnLostActive() OVERRIDE;
+
+ private:
+ aura::Window* window_;
+ bool window_was_active_;
+ bool activate_;
+ int activated_count_;
+ int lost_active_count_;
+ int should_activate_count_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestActivationDelegate);
+};
+
+} // namespace test
+} // namespace aura_shell
+
+#endif // ASH_TEST_TEST_ACTIVATION_DELEGATE_H_
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
new file mode 100644
index 0000000..eb289f4
--- /dev/null
+++ b/ash/test/test_shell_delegate.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2011 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.
+
+#include "ash/test/test_shell_delegate.h"
+
+namespace aura_shell {
+namespace test {
+
+TestShellDelegate::TestShellDelegate() {
+}
+
+TestShellDelegate::~TestShellDelegate() {
+}
+
+void TestShellDelegate::CreateNewWindow() {
+}
+
+views::Widget* TestShellDelegate::CreateStatusArea() {
+ return NULL;
+}
+
+void TestShellDelegate::RequestAppListWidget(
+ const gfx::Rect& bounds,
+ const SetWidgetCallback& callback) {
+}
+
+void TestShellDelegate::BuildAppListModel(AppListModel* model) {
+}
+
+AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() {
+ return NULL;
+}
+
+void TestShellDelegate::LauncherItemClicked(const LauncherItem& item) {
+}
+
+bool TestShellDelegate::ConfigureLauncherItem(LauncherItem* item) {
+ return true;
+}
+
+} // namespace test
+} // namespace aura_shell
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
new file mode 100644
index 0000000..6d922ca
--- /dev/null
+++ b/ash/test/test_shell_delegate.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2011 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_TEST_TEST_SHELL_DELEGATE_H_
+#define ASH_TEST_TEST_SHELL_DELEGATE_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "ui/aura_shell/shell_delegate.h"
+
+namespace aura_shell {
+namespace test {
+
+class TestShellDelegate : public ShellDelegate {
+ public:
+ TestShellDelegate();
+ virtual ~TestShellDelegate();
+
+ // Overridden from ShellDelegate:
+ virtual void CreateNewWindow() OVERRIDE;
+ virtual views::Widget* CreateStatusArea() OVERRIDE;
+ virtual void RequestAppListWidget(
+ const gfx::Rect& bounds,
+ const SetWidgetCallback& callback) OVERRIDE;
+ virtual void BuildAppListModel(AppListModel* model) OVERRIDE;
+ virtual AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
+ virtual void LauncherItemClicked(const LauncherItem& item) OVERRIDE;
+ virtual bool ConfigureLauncherItem(LauncherItem* item) OVERRIDE;
+};
+
+} // namespace test
+} // namespace aura_shell
+
+#endif // ASH_TEST_TEST_SHELL_DELEGATE_H_
diff --git a/ash/test/test_suite.cc b/ash/test/test_suite.cc
new file mode 100644
index 0000000..eb22a6b
--- /dev/null
+++ b/ash/test/test_suite.cc
@@ -0,0 +1,52 @@
+// Copyright (c) 2011 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.
+
+#include "ash/test/test_suite.h"
+
+#include "base/file_path.h"
+#include "base/path_service.h"
+#include "build/build_config.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+#include "ui/gfx/compositor/test/compositor_test_support.h"
+#include "ui/gfx/gfx_paths.h"
+
+#if defined(USE_WEBKIT_COMPOSITOR)
+#include "ui/gfx/compositor/compositor_setup.h"
+#else
+#include "ui/gfx/test/gfx_test_utils.h"
+#endif
+
+namespace aura_shell {
+namespace test {
+
+AuraShellTestSuite::AuraShellTestSuite(int argc, char** argv)
+ : TestSuite(argc, argv) {}
+
+void AuraShellTestSuite::Initialize() {
+ base::TestSuite::Initialize();
+
+ gfx::RegisterPathProvider();
+ ui::RegisterPathProvider();
+
+ // Force unittests to run using en-US so if we test against string
+ // output, it'll pass regardless of the system language.
+ ui::ResourceBundle::InitSharedInstance("en-US");
+ ui::CompositorTestSupport::Initialize();
+#if defined(USE_WEBKIT_COMPOSITOR)
+ ui::SetupTestCompositor();
+#else
+ ui::gfx_test_utils::SetupTestCompositor();
+#endif
+}
+
+void AuraShellTestSuite::Shutdown() {
+ ui::CompositorTestSupport::Terminate();
+ ui::ResourceBundle::CleanupSharedInstance();
+
+ base::TestSuite::Shutdown();
+}
+
+} // namespace test
+} // namespace aura_shell
diff --git a/ash/test/test_suite.h b/ash/test/test_suite.h
new file mode 100644
index 0000000..5a32b69
--- /dev/null
+++ b/ash/test/test_suite.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2011 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_TEST_TEST_SUITE_H_
+#define ASH_TEST_TEST_SUITE_H_
+#pragma once
+
+#include "base/compiler_specific.h"
+#include "base/test/test_suite.h"
+
+namespace aura_shell {
+namespace test {
+
+class AuraShellTestSuite : public base::TestSuite {
+ public:
+ AuraShellTestSuite(int argc, char** argv);
+
+ protected:
+ // base::TestSuite:
+ virtual void Initialize() OVERRIDE;
+ virtual void Shutdown() OVERRIDE;
+};
+
+} // namespace test
+} // namespace aura_shell
+
+#endif // ASH_TEST_TEST_SUITE_H_