blob: e1b5ac0c57013b4f5100e73dd259e48f78b3ac7b (
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 (c) 2010 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 "testing/gtest/include/gtest/gtest.h"
#include "base/ref_counted.h"
#include "chrome/renderer/mock_render_process.h"
#include "chrome/renderer/mock_render_thread.h"
#include "chrome/renderer/render_widget.h"
#include "chrome/renderer/render_thread.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h"
namespace {
const int32 kRouteId = 5;
const int32 kOpenerId = 7;
class RenderWidgetTest : public testing::Test {
public:
protected:
MessageLoop msg_loop_;
MockRenderThread render_thread_;
// The widget, each test should verify this is non-NULL before continuing.
scoped_refptr<RenderWidget> widget_;
private:
// testing::Test
virtual void SetUp() {
mock_process_.reset(new MockRenderProcess);
render_thread_.set_routing_id(kRouteId);
widget_ = RenderWidget::Create(kOpenerId, &render_thread_,
WebKit::WebPopupTypeNone);
ASSERT_TRUE(widget_);
}
virtual void TearDown() {
widget_ = NULL;
mock_process_.reset();
}
scoped_ptr<MockRenderProcess> mock_process_;
};
TEST_F(RenderWidgetTest, CreateAndCloseWidget) {
// After the RenderWidget it must have sent a message to the render thread
// that sets the opener id.
EXPECT_EQ(kOpenerId, render_thread_.opener_id());
ASSERT_TRUE(render_thread_.has_widget());
// Now simulate a close of the Widget.
render_thread_.SendCloseMessage();
EXPECT_FALSE(render_thread_.has_widget());
// Run the loop so the release task from the renderwidget executes.
msg_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask());
msg_loop_.Run();
}
} // namespace
|