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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
// Copyright (c) 2006-2008 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 "o3d/gpu_plugin/gpu_plugin_object.h"
#include "o3d/gpu_plugin/np_utils/base_np_object_mock.h"
#include "o3d/gpu_plugin/np_utils/np_browser_mock.h"
#include "o3d/gpu_plugin/np_utils/np_object_pointer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "webkit/glue/plugins/nphostapi.h"
using testing::_;
using testing::DoAll;
using testing::Return;
using testing::SetArgumentPointee;
using testing::StrictMock;
namespace o3d {
namespace gpu_plugin {
class GPUPluginObjectTest : public testing::Test {
protected:
virtual void SetUp() {
plugin_object_ = NPCreateObject<GPUPluginObject>(NULL);
}
MockNPBrowser mock_browser_;
NPObjectPointer<GPUPluginObject> plugin_object_;
};
TEST_F(GPUPluginObjectTest, CanInitializeAndDestroyPluginObject) {
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo",
0,
NULL,
NULL,
NULL));
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL));
}
TEST_F(GPUPluginObjectTest, DestroyFailsIfNotInitialized) {
EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_object_->Destroy(NULL));
}
TEST_F(GPUPluginObjectTest, NewFailsIfAlreadyInitialized) {
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo",
0,
NULL,
NULL,
NULL));
EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_object_->New("application/foo",
0,
NULL,
NULL,
NULL));
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL));
}
TEST_F(GPUPluginObjectTest, NewFailsIfObjectHasPreviouslyBeenDestroyed) {
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo",
0,
NULL,
NULL,
NULL));
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL));
EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_object_->New("application/foo",
0,
NULL,
NULL,
NULL));
}
TEST_F(GPUPluginObjectTest, WindowIsNullBeforeSetWindowCalled) {
NPWindow window = plugin_object_->GetWindow();
EXPECT_EQ(NULL, window.window);
}
TEST_F(GPUPluginObjectTest, CanSetWindow) {
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->New("application/foo",
0,
NULL,
NULL,
NULL));
NPWindow window = {0};
window.window = &window;
window.x = 7;
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->SetWindow(&window));
EXPECT_EQ(0, memcmp(&window, &plugin_object_->GetWindow(), sizeof(window)));
EXPECT_EQ(NPERR_NO_ERROR, plugin_object_->Destroy(NULL));
}
TEST_F(GPUPluginObjectTest, SetWindowFailsIfNotInitialized) {
NPWindow window = {0};
EXPECT_EQ(NPERR_GENERIC_ERROR, plugin_object_->SetWindow(&window));
}
TEST_F(GPUPluginObjectTest, CanGetScriptableNPObject) {
EXPECT_EQ(plugin_object_.Get(), plugin_object_->GetScriptableNPObject());
}
} // namespace gpu_plugin
} // namespace o3d
|