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

Side by Side Diff: extensions/common/stack_frame_unittest.cc

Issue 112963005: Update uses of UTF conversions in courgette/, device/, extensions/, google_apis/, gpu/, ipc/, media… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/stack_frame.h" 5 #include "extensions/common/stack_frame.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using base::UTF8ToUTF16; 13 using base::UTF8ToUTF16;
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 namespace { 17 namespace {
18 18
19 void AssertStackFrameValid(const std::string& text, 19 void AssertStackFrameValid(const std::string& text,
20 size_t line, 20 size_t line,
21 size_t column, 21 size_t column,
22 const std::string& source, 22 const std::string& source,
23 const std::string& function) { 23 const std::string& function) {
24 base::string16 utf16_text = UTF8ToUTF16(text); 24 base::string16 utf16_text = base::UTF8ToUTF16(text);
25 scoped_ptr<StackFrame> frame = StackFrame::CreateFromText(utf16_text); 25 scoped_ptr<StackFrame> frame = StackFrame::CreateFromText(utf16_text);
26 26
27 ASSERT_TRUE(frame.get()) << "Failed to create frame from '" << text << "'"; 27 ASSERT_TRUE(frame.get()) << "Failed to create frame from '" << text << "'";
28 EXPECT_EQ(line, frame->line_number()); 28 EXPECT_EQ(line, frame->line_number());
29 EXPECT_EQ(column, frame->column_number()); 29 EXPECT_EQ(column, frame->column_number());
30 EXPECT_EQ(UTF8ToUTF16(source), frame->source()); 30 EXPECT_EQ(base::UTF8ToUTF16(source), frame->source());
31 EXPECT_EQ(UTF8ToUTF16(function), frame->function()); 31 EXPECT_EQ(base::UTF8ToUTF16(function), frame->function());
32 } 32 }
33 33
34 void AssertStackFrameInvalid(const std::string& text) { 34 void AssertStackFrameInvalid(const std::string& text) {
35 base::string16 utf16_text = UTF8ToUTF16(text); 35 base::string16 utf16_text = base::UTF8ToUTF16(text);
36 scoped_ptr<StackFrame> frame = StackFrame::CreateFromText(utf16_text); 36 scoped_ptr<StackFrame> frame = StackFrame::CreateFromText(utf16_text);
37 ASSERT_FALSE(frame.get()) << "Errantly created frame from '" << text << "'"; 37 ASSERT_FALSE(frame.get()) << "Errantly created frame from '" << text << "'";
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 TEST(StackFrameUnitTest, ParseStackFramesFromText) { 42 TEST(StackFrameUnitTest, ParseStackFramesFromText) {
43 AssertStackFrameValid( 43 AssertStackFrameValid(
44 "function_name (https://www.url.com/foo.html:100:201)", 44 "function_name (https://www.url.com/foo.html:100:201)",
45 100u, 201u, "https://www.url.com/foo.html", "function_name"); 45 100u, 201u, "https://www.url.com/foo.html", "function_name");
(...skipping 30 matching lines...) Expand all
76 "function_name (https://www.url.com/foo.html:100:201a)"); 76 "function_name (https://www.url.com/foo.html:100:201a)");
77 // Negative column number. 77 // Negative column number.
78 AssertStackFrameInvalid( 78 AssertStackFrameInvalid(
79 "function_name (https://www.url.com/foo.html:100:-201)"); 79 "function_name (https://www.url.com/foo.html:100:-201)");
80 // Extra trailing ')' 80 // Extra trailing ')'
81 AssertStackFrameInvalid( 81 AssertStackFrameInvalid(
82 "function_name (https://www.url.com/foo.html:100:201))"); 82 "function_name (https://www.url.com/foo.html:100:201))");
83 } 83 }
84 84
85 } // namespace extensions 85 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/permissions/permissions_data_unittest.cc ('k') | google_apis/drive/gdata_wapi_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698