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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
// Copyright (c) 2012 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 <cstring>
#include "base/strings/utf_string_conversions.h"
#include "ppapi/c/dev/ppb_memory_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/proxy/pdf_resource.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/ppapi_proxy_test.h"
#include "ppapi/proxy/ppb_image_data_proxy.h"
#include "ppapi/proxy/serialized_handle.h"
#include "ppapi/shared_impl/proxy_lock.h"
#include "ppapi/shared_impl/scoped_pp_var.h"
#include "ppapi/shared_impl/var.h"
#include "ppapi/thunk/thunk.h"
namespace ppapi {
namespace proxy {
namespace {
typedef PluginProxyTest PDFResourceTest;
} // namespace
TEST_F(PDFResourceTest, SearchString) {
ProxyAutoLock lock;
// Instantiate a resource explicitly so we can specify the locale.
auto pdf_resource = base::MakeRefCounted<PDFResource>(
Connection(&sink(), &sink(), 0), pp_instance());
pdf_resource->SetLocaleForTest("en-US@collation=search");
base::string16 input;
base::string16 term;
base::UTF8ToUTF16("abcdefabcdef", 12, &input);
base::UTF8ToUTF16("bc", 2, &term);
PP_PrivateFindResult* results;
uint32_t count = 0;
pdf_resource->SearchString(
reinterpret_cast<const unsigned short*>(input.c_str()),
reinterpret_cast<const unsigned short*>(term.c_str()),
true,
&results,
&count);
ASSERT_EQ(2U, count);
ASSERT_EQ(1, results[0].start_index);
ASSERT_EQ(2, results[0].length);
ASSERT_EQ(7, results[1].start_index);
ASSERT_EQ(2, results[1].length);
const PPB_Memory_Dev* memory_iface = thunk::GetPPB_Memory_Dev_0_1_Thunk();
memory_iface->MemFree(results);
}
TEST_F(PDFResourceTest, DidStartLoading) {
const PPB_PDF* pdf_iface = thunk::GetPPB_PDF_Thunk();
pdf_iface->DidStartLoading(pp_instance());
ResourceMessageCallParams params;
IPC::Message msg;
ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_PDF_DidStartLoading::ID, ¶ms, &msg));
}
TEST_F(PDFResourceTest, DidStopLoading) {
const PPB_PDF* pdf_iface = thunk::GetPPB_PDF_Thunk();
pdf_iface->DidStopLoading(pp_instance());
ResourceMessageCallParams params;
IPC::Message msg;
ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_PDF_DidStopLoading::ID, ¶ms, &msg));
}
TEST_F(PDFResourceTest, SetContentRestriction) {
const PPB_PDF* pdf_iface = thunk::GetPPB_PDF_Thunk();
int restrictions = 5;
pdf_iface->SetContentRestriction(pp_instance(), restrictions);
ResourceMessageCallParams params;
IPC::Message msg;
ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_PDF_SetContentRestriction::ID, ¶ms, &msg));
}
TEST_F(PDFResourceTest, HasUnsupportedFeature) {
const PPB_PDF* pdf_iface = thunk::GetPPB_PDF_Thunk();
pdf_iface->HasUnsupportedFeature(pp_instance());
ResourceMessageCallParams params;
IPC::Message msg;
ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_PDF_HasUnsupportedFeature::ID, ¶ms, &msg));
}
TEST_F(PDFResourceTest, Print) {
const PPB_PDF* pdf_iface = thunk::GetPPB_PDF_Thunk();
pdf_iface->Print(pp_instance());
ResourceMessageCallParams params;
IPC::Message msg;
ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_PDF_Print::ID, ¶ms, &msg));
}
TEST_F(PDFResourceTest, SaveAs) {
const PPB_PDF* pdf_iface = thunk::GetPPB_PDF_Thunk();
pdf_iface->SaveAs(pp_instance());
ResourceMessageCallParams params;
IPC::Message msg;
ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_PDF_SaveAs::ID, ¶ms, &msg));
}
TEST_F(PDFResourceTest, SelectionChanged) {
const PPB_PDF* pdf_iface = thunk::GetPPB_PDF_Thunk();
PP_FloatPoint left = PP_MakeFloatPoint(0.0f, 0.0f);
PP_FloatPoint right = PP_MakeFloatPoint(1.0f, 1.0f);
pdf_iface->SelectionChanged(pp_instance(), &left, 0, &right, 0);
ResourceMessageCallParams params;
IPC::Message msg;
ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_PDF_SelectionChanged::ID, ¶ms, &msg));
}
TEST_F(PDFResourceTest, SetPluginCanSave) {
const PPB_PDF* pdf_iface = thunk::GetPPB_PDF_Thunk();
pdf_iface->SetPluginCanSave(pp_instance(), true);
ResourceMessageCallParams params;
IPC::Message msg;
ASSERT_TRUE(sink().GetFirstResourceCallMatching(
PpapiHostMsg_PDF_SetPluginCanSave::ID, ¶ms, &msg));
}
} // namespace proxy
} // namespace ppapi
|