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 "chrome/browser/chromeos/drive/file_system/touch_operation.h"
7 #include "base/files/file_path.h"
8 #include "base/time/time.h"
9 #include "chrome/browser/chromeos/drive/file_system/operation_test_base.h"
10 #include "components/drive/drive.pb.h"
11 #include "components/drive/file_errors.h"
12 #include "components/drive/resource_metadata.h"
13 #include "google_apis/drive/test_util.h"
14 #include "testing/gtest/include/gtest/gtest.h"
17 namespace file_system
{
19 typedef OperationTestBase TouchOperationTest
;
21 TEST_F(TouchOperationTest
, TouchFile
) {
22 TouchOperation
operation(blocking_task_runner(),
26 const base::FilePath
kTestPath(FILE_PATH_LITERAL("drive/root/File 1.txt"));
27 const base::Time::Exploded kLastAccessTime
= {
28 2012, 7, 0, 19, 15, 59, 13, 123
30 const base::Time::Exploded kLastModifiedTime
= {
31 2013, 7, 0, 19, 15, 59, 13, 123
34 FileError error
= FILE_ERROR_FAILED
;
37 base::Time::FromUTCExploded(kLastAccessTime
),
38 base::Time::FromUTCExploded(kLastModifiedTime
),
39 google_apis::test_util::CreateCopyResultCallback(&error
));
40 content::RunAllBlockingPoolTasksUntilIdle();
41 EXPECT_EQ(FILE_ERROR_OK
, error
);
44 EXPECT_EQ(FILE_ERROR_OK
, GetLocalResourceEntry(kTestPath
, &entry
));
45 EXPECT_EQ(base::Time::FromUTCExploded(kLastAccessTime
),
46 base::Time::FromInternalValue(entry
.file_info().last_accessed()));
47 EXPECT_EQ(base::Time::FromUTCExploded(kLastModifiedTime
),
48 base::Time::FromInternalValue(entry
.file_info().last_modified()));
49 EXPECT_EQ(ResourceEntry::DIRTY
, entry
.metadata_edit_state());
51 EXPECT_EQ(1U, delegate()->get_changed_files().size());
52 EXPECT_TRUE(delegate()->get_changed_files().count(kTestPath
));
54 EXPECT_EQ(1U, delegate()->updated_local_ids().size());
55 EXPECT_TRUE(delegate()->updated_local_ids().count(entry
.local_id()));
58 } // namespace file_system