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

Side by Side Diff: webkit/fileapi/media/picasa/pmp_table_reader_unittest.cc

Issue 14247034: Move Media Galleries FileAPI code out of webkit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cr-14352004
Patch Set: Add android ifdef. 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
OLDNEW
(Empty)
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.
4
5 #include <algorithm>
6 #include <vector>
7
8 #include "base/file_util.h"
9 #include "base/utf_string_conversions.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "webkit/fileapi/media/picasa/pmp_column_reader.h"
12 #include "webkit/fileapi/media/picasa/pmp_constants.h"
13 #include "webkit/fileapi/media/picasa/pmp_table_reader.h"
14 #include "webkit/fileapi/media/picasa/pmp_test_helper.h"
15
16 namespace {
17
18 using picasaimport::PmpTestHelper;
19
20 TEST(PmpTableReaderTest, RowCountAndFieldType) {
21 PmpTestHelper test_helper;
22 ASSERT_TRUE(test_helper.Init());
23
24 std::string table_name = "testtable";
25
26 std::vector<std::string> column_names;
27 column_names.push_back("strings");
28 column_names.push_back("uint32s");
29 column_names.push_back("doubles");
30
31 const std::vector<std::string> strings_vector(10, "Hello");
32 const std::vector<uint32> uint32s_vector(30, 42);
33 const std::vector<double> doubles_vector(20, 0.5);
34
35 picasaimport::PmpFieldType column_field_types[] = {
36 picasaimport::PMP_TYPE_STRING,
37 picasaimport::PMP_TYPE_UINT32,
38 picasaimport::PMP_TYPE_DOUBLE64
39 };
40
41 const uint32 max_rows = uint32s_vector.size();
42
43 base::FilePath indicator_path = test_helper.GetTempDirPath().Append(
44 base::FilePath::FromUTF8Unsafe(table_name + "_0"));
45
46 ASSERT_EQ(0, file_util::WriteFile(indicator_path, NULL, 0));
47 // Write three column files, one each for strings, uint32s, and doubles.
48
49 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
50 table_name, column_names[0], column_field_types[0], strings_vector));
51
52 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
53 table_name, column_names[1], column_field_types[1], uint32s_vector));
54
55 ASSERT_TRUE(test_helper.WriteColumnFileFromVector(
56 table_name, column_names[2], column_field_types[2], doubles_vector));
57
58 picasaimport::PmpTableReader table_reader;
59 ASSERT_TRUE(table_reader.Init(
60 table_name, test_helper.GetTempDirPath(), column_names));
61
62 EXPECT_EQ(max_rows, table_reader.RowCount());
63
64 const std::vector<const picasaimport::PmpColumnReader*> column_readers =
65 table_reader.GetColumns();
66
67 for (int i = 0; i < 3; i++) {
68 EXPECT_EQ(column_field_types[i], column_readers[i]->field_type());
69 }
70 }
71
72 } // namespace
OLDNEW
« no previous file with comments | « webkit/fileapi/media/picasa/pmp_table_reader.cc ('k') | webkit/fileapi/media/picasa/pmp_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698