Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / media_galleries / linux / mtp_device_object_enumerator_unittest.cc
blob77e14b43ba6621a25a6ecb063f8af872edc56be0
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
3 // found in the LICENSE file.
5 #include "chrome/browser/media_galleries/linux/mtp_device_object_enumerator.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 namespace {
10 struct MtpFileEntryData {
11 const char* const name;
12 int64 size;
13 bool is_directory;
14 time_t modification_time;
17 const MtpFileEntryData kTestCases[] = {
18 { "Foo", 123, false, 321 },
19 { "Bar", 234, true, 432 },
20 { "Baaz", 345, false, 543 },
23 void TestEnumeratorIsEmpty(MTPDeviceObjectEnumerator* enumerator) {
24 EXPECT_EQ(0, enumerator->Size());
25 EXPECT_FALSE(enumerator->IsDirectory());
26 EXPECT_TRUE(enumerator->LastModifiedTime().is_null());
29 void TestNextEntryIsEmpty(MTPDeviceObjectEnumerator* enumerator) {
30 EXPECT_TRUE(enumerator->Next().empty());
33 typedef testing::Test MTPDeviceObjectEnumeratorTest;
35 TEST_F(MTPDeviceObjectEnumeratorTest, Empty) {
36 std::vector<MtpFileEntry> entries;
37 MTPDeviceObjectEnumerator enumerator(entries);
38 TestEnumeratorIsEmpty(&enumerator);
39 TestNextEntryIsEmpty(&enumerator);
40 TestNextEntryIsEmpty(&enumerator);
41 TestEnumeratorIsEmpty(&enumerator);
44 TEST_F(MTPDeviceObjectEnumeratorTest, Traversal) {
45 std::vector<MtpFileEntry> entries;
46 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
47 MtpFileEntry entry;
48 entry.set_file_name(kTestCases[i].name);
49 entry.set_file_size(kTestCases[i].size);
50 entry.set_file_type(kTestCases[i].is_directory ?
51 MtpFileEntry::FILE_TYPE_FOLDER :
52 MtpFileEntry::FILE_TYPE_OTHER);
53 entry.set_modification_time(kTestCases[i].modification_time);
54 entries.push_back(entry);
56 MTPDeviceObjectEnumerator enumerator(entries);
57 TestEnumeratorIsEmpty(&enumerator);
58 TestEnumeratorIsEmpty(&enumerator);
59 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
60 EXPECT_EQ(kTestCases[i].name, enumerator.Next().value());
61 EXPECT_EQ(kTestCases[i].size, enumerator.Size());
62 EXPECT_EQ(kTestCases[i].is_directory, enumerator.IsDirectory());
63 EXPECT_EQ(kTestCases[i].modification_time,
64 enumerator.LastModifiedTime().ToTimeT());
66 TestNextEntryIsEmpty(&enumerator);
67 TestNextEntryIsEmpty(&enumerator);
68 TestEnumeratorIsEmpty(&enumerator);
69 TestNextEntryIsEmpty(&enumerator);
70 TestEnumeratorIsEmpty(&enumerator);
73 } // namespace