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

Side by Side Diff: extensions/renderer/activity_log_converter_strategy_unittest.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium 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 "extensions/renderer/activity_log_converter_strategy.h" 5 #include "extensions/renderer/activity_log_converter_strategy.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 15 matching lines...) Expand all
26 void SetUp() override { 26 void SetUp() override {
27 converter_.reset(V8ValueConverter::create()); 27 converter_.reset(V8ValueConverter::create());
28 strategy_.reset(new ActivityLogConverterStrategy()); 28 strategy_.reset(new ActivityLogConverterStrategy());
29 converter_->SetFunctionAllowed(true); 29 converter_->SetFunctionAllowed(true);
30 converter_->SetStrategy(strategy_.get()); 30 converter_->SetStrategy(strategy_.get());
31 } 31 }
32 32
33 testing::AssertionResult VerifyNull(v8::Local<v8::Value> v8_value) { 33 testing::AssertionResult VerifyNull(v8::Local<v8::Value> v8_value) {
34 std::unique_ptr<base::Value> value( 34 std::unique_ptr<base::Value> value(
35 converter_->FromV8Value(v8_value, context())); 35 converter_->FromV8Value(v8_value, context()));
36 if (value->IsType(base::Value::TYPE_NULL)) 36 if (value->IsType(base::Value::Type::NONE))
37 return testing::AssertionSuccess(); 37 return testing::AssertionSuccess();
38 return testing::AssertionFailure(); 38 return testing::AssertionFailure();
39 } 39 }
40 40
41 testing::AssertionResult VerifyBoolean(v8::Local<v8::Value> v8_value, 41 testing::AssertionResult VerifyBoolean(v8::Local<v8::Value> v8_value,
42 bool expected) { 42 bool expected) {
43 bool out; 43 bool out;
44 std::unique_ptr<base::Value> value( 44 std::unique_ptr<base::Value> value(
45 converter_->FromV8Value(v8_value, context())); 45 converter_->FromV8Value(v8_value, context()));
46 if (value->IsType(base::Value::TYPE_BOOLEAN) 46 if (value->IsType(base::Value::Type::BOOLEAN)
47 && value->GetAsBoolean(&out) 47 && value->GetAsBoolean(&out)
48 && out == expected) 48 && out == expected)
49 return testing::AssertionSuccess(); 49 return testing::AssertionSuccess();
50 return testing::AssertionFailure(); 50 return testing::AssertionFailure();
51 } 51 }
52 52
53 testing::AssertionResult VerifyInteger(v8::Local<v8::Value> v8_value, 53 testing::AssertionResult VerifyInteger(v8::Local<v8::Value> v8_value,
54 int expected) { 54 int expected) {
55 int out; 55 int out;
56 std::unique_ptr<base::Value> value( 56 std::unique_ptr<base::Value> value(
57 converter_->FromV8Value(v8_value, context())); 57 converter_->FromV8Value(v8_value, context()));
58 if (value->IsType(base::Value::TYPE_INTEGER) 58 if (value->IsType(base::Value::Type::INTEGER)
59 && value->GetAsInteger(&out) 59 && value->GetAsInteger(&out)
60 && out == expected) 60 && out == expected)
61 return testing::AssertionSuccess(); 61 return testing::AssertionSuccess();
62 return testing::AssertionFailure(); 62 return testing::AssertionFailure();
63 } 63 }
64 64
65 testing::AssertionResult VerifyDouble(v8::Local<v8::Value> v8_value, 65 testing::AssertionResult VerifyDouble(v8::Local<v8::Value> v8_value,
66 double expected) { 66 double expected) {
67 double out; 67 double out;
68 std::unique_ptr<base::Value> value( 68 std::unique_ptr<base::Value> value(
69 converter_->FromV8Value(v8_value, context())); 69 converter_->FromV8Value(v8_value, context()));
70 if (value->IsType(base::Value::TYPE_DOUBLE) 70 if (value->IsType(base::Value::Type::DOUBLE)
71 && value->GetAsDouble(&out) 71 && value->GetAsDouble(&out)
72 && out == expected) 72 && out == expected)
73 return testing::AssertionSuccess(); 73 return testing::AssertionSuccess();
74 return testing::AssertionFailure(); 74 return testing::AssertionFailure();
75 } 75 }
76 76
77 testing::AssertionResult VerifyString(v8::Local<v8::Value> v8_value, 77 testing::AssertionResult VerifyString(v8::Local<v8::Value> v8_value,
78 const std::string& expected) { 78 const std::string& expected) {
79 std::string out; 79 std::string out;
80 std::unique_ptr<base::Value> value( 80 std::unique_ptr<base::Value> value(
81 converter_->FromV8Value(v8_value, context())); 81 converter_->FromV8Value(v8_value, context()));
82 if (value->IsType(base::Value::TYPE_STRING) 82 if (value->IsType(base::Value::Type::STRING)
83 && value->GetAsString(&out) 83 && value->GetAsString(&out)
84 && out == expected) 84 && out == expected)
85 return testing::AssertionSuccess(); 85 return testing::AssertionSuccess();
86 return testing::AssertionFailure(); 86 return testing::AssertionFailure();
87 } 87 }
88 88
89 v8::Local<v8::Context> context() const { 89 v8::Local<v8::Context> context() const {
90 return v8::Local<v8::Context>::New(isolate_, context_); 90 return v8::Local<v8::Context>::New(isolate_, context_);
91 } 91 }
92 92
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 "[Array]")); 165 "[Array]"));
166 EXPECT_TRUE(VerifyString( 166 EXPECT_TRUE(VerifyString(
167 v8_object->Get(v8::String::NewFromUtf8(isolate_, "function")), 167 v8_object->Get(v8::String::NewFromUtf8(isolate_, "function")),
168 "[Function]")); 168 "[Function]"));
169 EXPECT_TRUE(VerifyString( 169 EXPECT_TRUE(VerifyString(
170 v8_object->Get(v8::String::NewFromUtf8(isolate_, "named_function")), 170 v8_object->Get(v8::String::NewFromUtf8(isolate_, "named_function")),
171 "[Function foo()]")); 171 "[Function foo()]"));
172 } 172 }
173 173
174 } // namespace extensions 174 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/manifest_handlers/background_info.cc ('k') | extensions/renderer/event_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698