summaryrefslogtreecommitdiffstats
path: root/ash/test/ash_test_helper_unittest.cc
blob: f5eae6006b93d9cbdde5b5dd5bd32277e881e864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2013 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/ash_test_helper.h"

#include "testing/gtest/include/gtest/gtest.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/views/widget/widget.h"

#if defined(OS_WIN)
#include "base/win/windows_version.h"
#endif

// Tests for AshTestHelper. Who will watch the watchers? And who will test
// the tests?
class AshTestHelperTest : public testing::Test {
 public:
  AshTestHelperTest() {}
  virtual ~AshTestHelperTest() {}

  virtual void SetUp() OVERRIDE {
    testing::Test::SetUp();
    ash_test_helper_.reset(new ash::test::AshTestHelper(&message_loop_));
    ash_test_helper_->SetUp(true);
  }

  virtual void TearDown() OVERRIDE {
    ash_test_helper_->TearDown();
    testing::Test::TearDown();
  }

  ash::test::AshTestHelper* ash_test_helper() {
    return ash_test_helper_.get();
  }

 private:
  base::MessageLoopForUI message_loop_;
  scoped_ptr<ash::test::AshTestHelper> ash_test_helper_;

  DISALLOW_COPY_AND_ASSIGN(AshTestHelperTest);
};

// Ensure that we have initialized enough of Ash to create and show a window.
TEST_F(AshTestHelperTest, AshTestHelper) {
  // Check initial state.
  EXPECT_TRUE(ash_test_helper()->message_loop());
  EXPECT_TRUE(ash_test_helper()->test_shell_delegate());
  EXPECT_TRUE(ash_test_helper()->CurrentContext());

  // Enough state is initialized to create a window.
  using views::Widget;
  scoped_ptr<Widget> w1(new Widget);
  Widget::InitParams params;
  params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
  params.context = ash_test_helper()->CurrentContext();
  w1->Init(params);
  w1->Show();
  EXPECT_TRUE(w1->IsActive());
  EXPECT_TRUE(w1->IsVisible());
}