Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(457)

Side by Side Diff: fpdfsdk/javascript/public_methods_embeddertest.cpp

Issue 2026933002: Remove use of v8:Lockers (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/javascript/cjs_runtime.cpp ('k') | fpdfsdk/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 PDFium Authors. All rights reserved. 1 // Copyright 2015 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cmath> 5 #include <cmath>
6 6
7 #include "core/fxcrt/include/fx_string.h" 7 #include "core/fxcrt/include/fx_string.h"
8 #include "fpdfsdk/javascript/PublicMethods.h" 8 #include "fpdfsdk/javascript/PublicMethods.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/js_embedder_test.h" 10 #include "testing/js_embedder_test.h"
11 11
12 namespace { 12 namespace {
13 13
14 double RoundDownDate(double date) { 14 double RoundDownDate(double date) {
15 return date - fmod(date, 86400000); 15 return date - fmod(date, 86400000);
16 } 16 }
17 17
18 } // namespace 18 } // namespace
19 19
20 class PublicMethodsEmbedderTest : public JSEmbedderTest {}; 20 class PublicMethodsEmbedderTest : public JSEmbedderTest {};
21 21
22 TEST_F(PublicMethodsEmbedderTest, MakeRegularDate) { 22 TEST_F(PublicMethodsEmbedderTest, MakeRegularDate) {
23 v8::Isolate::Scope isolate_scope(isolate()); 23 v8::Isolate::Scope isolate_scope(isolate());
24 #ifdef PDF_ENABLE_XFA
25 v8::Locker locker(isolate());
26 #endif // PDF_ENABLE_XFA
27 v8::HandleScope handle_scope(isolate()); 24 v8::HandleScope handle_scope(isolate());
28 v8::Context::Scope context_scope(GetV8Context()); 25 v8::Context::Scope context_scope(GetV8Context());
29 bool bWrongFormat; 26 bool bWrongFormat;
30 double date; 27 double date;
31 28
32 // 1968 29 // 1968
33 bWrongFormat = false; 30 bWrongFormat = false;
34 date = CJS_PublicMethods::MakeRegularDate(L"06/25/1968", L"mm/dd/yyyy", 31 date = CJS_PublicMethods::MakeRegularDate(L"06/25/1968", L"mm/dd/yyyy",
35 &bWrongFormat); 32 &bWrongFormat);
36 date = RoundDownDate(date); 33 date = RoundDownDate(date);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bWrongFormat = false; 94 bWrongFormat = false;
98 date = 95 date =
99 CJS_PublicMethods::MakeRegularDate(L"010205", L"ddmmyy", &bWrongFormat); 96 CJS_PublicMethods::MakeRegularDate(L"010205", L"ddmmyy", &bWrongFormat);
100 date = RoundDownDate(date); 97 date = RoundDownDate(date);
101 EXPECT_DOUBLE_EQ(1107216000000.0, date); 98 EXPECT_DOUBLE_EQ(1107216000000.0, date);
102 EXPECT_FALSE(bWrongFormat); 99 EXPECT_FALSE(bWrongFormat);
103 } 100 }
104 101
105 TEST_F(PublicMethodsEmbedderTest, MakeFormatDate) { 102 TEST_F(PublicMethodsEmbedderTest, MakeFormatDate) {
106 v8::Isolate::Scope isolate_scope(isolate()); 103 v8::Isolate::Scope isolate_scope(isolate());
107 #ifdef PDF_ENABLE_XFA
108 v8::Locker locker(isolate());
109 #endif // PDF_ENABLE_XFA
110 v8::HandleScope handle_scope(isolate()); 104 v8::HandleScope handle_scope(isolate());
111 v8::Context::Scope context_scope(GetV8Context()); 105 v8::Context::Scope context_scope(GetV8Context());
112 CFX_WideString formatted_date; 106 CFX_WideString formatted_date;
113 107
114 // 1968-06-25 108 // 1968-06-25
115 formatted_date = CJS_PublicMethods::MakeFormatDate(-47952000000, L"ddmmyy"); 109 formatted_date = CJS_PublicMethods::MakeFormatDate(-47952000000, L"ddmmyy");
116 EXPECT_STREQ(L"250668", formatted_date.c_str()); 110 EXPECT_STREQ(L"250668", formatted_date.c_str());
117 formatted_date = CJS_PublicMethods::MakeFormatDate(-47952000000, L"yy/mm/dd"); 111 formatted_date = CJS_PublicMethods::MakeFormatDate(-47952000000, L"yy/mm/dd");
118 EXPECT_STREQ(L"68/06/25", formatted_date.c_str()); 112 EXPECT_STREQ(L"68/06/25", formatted_date.c_str());
119 113
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 EXPECT_STREQ(L"208531", formatted_date.c_str()); 153 EXPECT_STREQ(L"208531", formatted_date.c_str());
160 154
161 // 2095-02-01 155 // 2095-02-01
162 formatted_date = 156 formatted_date =
163 CJS_PublicMethods::MakeFormatDate(3947356800000.0, L"ddmmyy"); 157 CJS_PublicMethods::MakeFormatDate(3947356800000.0, L"ddmmyy");
164 EXPECT_STREQ(L"010295", formatted_date.c_str()); 158 EXPECT_STREQ(L"010295", formatted_date.c_str());
165 formatted_date = 159 formatted_date =
166 CJS_PublicMethods::MakeFormatDate(3947356800000.0, L"mmddyyyy"); 160 CJS_PublicMethods::MakeFormatDate(3947356800000.0, L"mmddyyyy");
167 EXPECT_STREQ(L"02012095", formatted_date.c_str()); 161 EXPECT_STREQ(L"02012095", formatted_date.c_str());
168 } 162 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/cjs_runtime.cpp ('k') | fpdfsdk/jsapi/fxjs_v8.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698