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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_files_unittest.cc

Issue 10384204: gdata: Fix a bug that caused google drive not to load (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix DCHECK failure in test Created 8 years, 7 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 | « chrome/browser/chromeos/gdata/gdata_files.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 "chrome/browser/chromeos/gdata/gdata_files.h" 5 #include "chrome/browser/chromeos/gdata/gdata_files.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 #include "chrome/browser/chromeos/gdata/gdata.pb.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace gdata { 13 namespace gdata {
13 14
14 TEST(GDataRootDirectoryTest, RemoveTemporaryFilesFromCacheMap) { 15 TEST(GDataRootDirectoryTest, RemoveTemporaryFilesFromCacheMap) {
15 scoped_ptr<GDataRootDirectory> root(new GDataRootDirectory); 16 scoped_ptr<GDataRootDirectory> root(new GDataRootDirectory);
16 GDataRootDirectory::CacheMap cache_map; 17 GDataRootDirectory::CacheMap cache_map;
17 cache_map.insert(std::make_pair( 18 cache_map.insert(std::make_pair(
18 "<resource_id_1>", 19 "<resource_id_1>",
19 new GDataRootDirectory::CacheEntry( 20 new GDataRootDirectory::CacheEntry(
(...skipping 21 matching lines...) Expand all
41 root->SetCacheMap(cache_map); 42 root->SetCacheMap(cache_map);
42 root->RemoveTemporaryFilesFromCacheMap(); 43 root->RemoveTemporaryFilesFromCacheMap();
43 // resource 1 and 4 should be gone, as these are CACHE_TYPE_TMP. 44 // resource 1 and 4 should be gone, as these are CACHE_TYPE_TMP.
44 ASSERT_TRUE(root->GetCacheEntry("<resource_id_1>", "") == NULL); 45 ASSERT_TRUE(root->GetCacheEntry("<resource_id_1>", "") == NULL);
45 ASSERT_TRUE(root->GetCacheEntry("<resource_id_2>", "") != NULL); 46 ASSERT_TRUE(root->GetCacheEntry("<resource_id_2>", "") != NULL);
46 ASSERT_TRUE(root->GetCacheEntry("<resource_id_3>", "") != NULL); 47 ASSERT_TRUE(root->GetCacheEntry("<resource_id_3>", "") != NULL);
47 ASSERT_TRUE(root->GetCacheEntry("<resource_id_4>", "") == NULL); 48 ASSERT_TRUE(root->GetCacheEntry("<resource_id_4>", "") == NULL);
48 49
49 } 50 }
50 51
52 TEST(GDataRootDirectoryTest, ParseFromString_DetectBadTitle) {
53 GDataRootDirectoryProto proto;
54 GDataEntryProto* mutable_entry =
55 proto.mutable_gdata_directory()->mutable_gdata_entry();
56 mutable_entry->mutable_file_info()->set_is_directory(true);
57
58 std::string serialized_proto;
59 ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
60
61 GDataRootDirectory root;
62 // This should fail as the title is empty.
63 // root.title() should be unchanged.
64 ASSERT_FALSE(root.ParseFromString(serialized_proto));
65 ASSERT_EQ("drive", root.title());
66
67 // Setting the title to "gdata".
68 mutable_entry->set_title("gdata");
69 ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
70
71 // This should fail as the title is not "drive".
72 // root.title() should be unchanged.
73 ASSERT_FALSE(root.ParseFromString(serialized_proto));
74 ASSERT_EQ("drive", root.title());
75
76 // Setting the title to "drive".
77 mutable_entry->set_title("drive");
78 ASSERT_TRUE(proto.SerializeToString(&serialized_proto));
79
80 // This should succeed as the title is "drive".
81 ASSERT_TRUE(root.ParseFromString(serialized_proto));
82 ASSERT_EQ("drive", root.title());
83 }
84
51 } // namespace gdata 85 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_files.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698