Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / upload_list_unittest.cc
blob153f9db631c02da48b450d58fd524bb3d54d0827
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
3 // found in the LICENSE file.
5 #include <string>
7 #include "base/files/file_path.h"
8 #include "base/memory/ref_counted.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "base/time/time.h"
11 #include "chrome/browser/upload_list.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 // Test that UploadList can parse a vector of log entry strings to a vector of
15 // UploadInfo objects. See the UploadList declaration for a description of the
16 // log entry string format.
17 TEST(UploadListTest, ParseLogEntries) {
18 const char kTestTime[] = "1234567890";
19 const char kTestID[] = "0123456789abcdef";
20 std::string test_entry = kTestTime;
21 test_entry += ",";
22 test_entry.append(kTestID, sizeof(kTestID));
24 scoped_refptr<UploadList> upload_list =
25 new UploadList(NULL, base::FilePath());
27 // 1 entry.
28 std::vector<std::string> log_entries;
29 log_entries.push_back(test_entry);
30 upload_list->ParseLogEntries(log_entries);
31 EXPECT_EQ(1u, upload_list->uploads_.size());
32 double time_double = upload_list->uploads_[0].time.ToDoubleT();
33 EXPECT_STREQ(kTestTime, base::DoubleToString(time_double).c_str());
34 EXPECT_STREQ(kTestID, upload_list->uploads_[0].id.c_str());
36 // Add 3 more entries.
37 log_entries.push_back(test_entry);
38 log_entries.push_back(test_entry);
39 upload_list->ParseLogEntries(log_entries);
40 EXPECT_EQ(4u, upload_list->uploads_.size());
41 time_double = upload_list->uploads_[3].time.ToDoubleT();
42 EXPECT_STREQ(kTestTime, base::DoubleToString(time_double).c_str());
43 EXPECT_STREQ(kTestID, upload_list->uploads_[3].id.c_str());