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

Side by Side Diff: base/debug/trace_event_unittest.cc

Issue 14244010: Correctly handle multiple convertable argument names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/debug/trace_event_unittest.h" 5 #include "base/debug/trace_event_unittest.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 private: 1629 private:
1630 DISALLOW_COPY_AND_ASSIGN(MyData); 1630 DISALLOW_COPY_AND_ASSIGN(MyData);
1631 }; 1631 };
1632 1632
1633 TEST_F(TraceEventTestFixture, ConvertableTypes) { 1633 TEST_F(TraceEventTestFixture, ConvertableTypes) {
1634 ManualTestSetUp(); 1634 ManualTestSetUp();
1635 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"), 1635 TraceLog::GetInstance()->SetEnabled(CategoryFilter("*"),
1636 TraceLog::RECORD_UNTIL_FULL); 1636 TraceLog::RECORD_UNTIL_FULL);
1637 1637
1638 scoped_ptr<MyData> data(new MyData()); 1638 scoped_ptr<MyData> data(new MyData());
1639 scoped_ptr<MyData> data1(new MyData());
1640 scoped_ptr<MyData> data2(new MyData());
1639 TRACE_EVENT1("foo", "bar", "data", 1641 TRACE_EVENT1("foo", "bar", "data",
1640 data.PassAs<base::debug::ConvertableToTraceFormat>()); 1642 data.PassAs<base::debug::ConvertableToTraceFormat>());
1643 TRACE_EVENT2("foo", "baz",
1644 "data1", data1.PassAs<base::debug::ConvertableToTraceFormat>(),
1645 "data2", data2.PassAs<base::debug::ConvertableToTraceFormat>());
1646
1641 EndTraceAndFlush(); 1647 EndTraceAndFlush();
1642 1648
1643 DictionaryValue* dict = FindNamePhase("bar", "B"); 1649 DictionaryValue* dict = FindNamePhase("bar", "B");
1644 ASSERT_TRUE(dict); 1650 ASSERT_TRUE(dict);
1645 1651
1646 const DictionaryValue* args_dict = NULL; 1652 const DictionaryValue* args_dict = NULL;
1647 dict->GetDictionary("args", &args_dict); 1653 dict->GetDictionary("args", &args_dict);
1648 ASSERT_TRUE(args_dict); 1654 ASSERT_TRUE(args_dict);
1649 1655
1650 const Value* value = NULL; 1656 const Value* value = NULL;
1651 const DictionaryValue* convertable_dict = NULL; 1657 const DictionaryValue* convertable_dict = NULL;
1652 EXPECT_TRUE(args_dict->Get("data", &value)); 1658 EXPECT_TRUE(args_dict->Get("data", &value));
1653 ASSERT_TRUE(value->GetAsDictionary(&convertable_dict)); 1659 ASSERT_TRUE(value->GetAsDictionary(&convertable_dict));
1654 1660
1655 int foo_val; 1661 int foo_val;
1656 EXPECT_TRUE(convertable_dict->GetInteger("foo", &foo_val)); 1662 EXPECT_TRUE(convertable_dict->GetInteger("foo", &foo_val));
1657 EXPECT_EQ(1, foo_val); 1663 EXPECT_EQ(1, foo_val);
1664
1665 dict = FindNamePhase("baz", "B");
1666 ASSERT_TRUE(dict);
1667 args_dict = NULL;
1668 dict->GetDictionary("args", &args_dict);
1669 ASSERT_TRUE(args_dict);
1670
1671 value = NULL;
1672 convertable_dict = NULL;
1673 EXPECT_TRUE(args_dict->Get("data1", &value));
1674 ASSERT_TRUE(value->GetAsDictionary(&convertable_dict));
1675
1676 value = NULL;
1677 convertable_dict = NULL;
1678 EXPECT_TRUE(args_dict->Get("data2", &value));
1679 ASSERT_TRUE(value->GetAsDictionary(&convertable_dict));
1658 } 1680 }
1659 1681
1660 1682
1661 class TraceEventCallbackTest : public TraceEventTestFixture { 1683 class TraceEventCallbackTest : public TraceEventTestFixture {
1662 public: 1684 public:
1663 virtual void SetUp() OVERRIDE { 1685 virtual void SetUp() OVERRIDE {
1664 TraceEventTestFixture::SetUp(); 1686 TraceEventTestFixture::SetUp();
1665 ManualTestSetUp(); 1687 ManualTestSetUp();
1666 ASSERT_EQ(NULL, s_instance); 1688 ASSERT_EQ(NULL, s_instance);
1667 s_instance = this; 1689 s_instance = this;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1809 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1788 " bad_category ")); 1810 " bad_category "));
1789 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1811 EXPECT_TRUE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1790 "")); 1812 ""));
1791 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace( 1813 EXPECT_FALSE(CategoryFilter::IsEmptyOrContainsLeadingOrTrailingWhitespace(
1792 "good_category")); 1814 "good_category"));
1793 } 1815 }
1794 1816
1795 } // namespace debug 1817 } // namespace debug
1796 } // namespace base 1818 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698