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

Side by Side Diff: chrome/browser/policy/device_token_fetcher_unittest.cc

Issue 5166001: Revert 66415 - CrOS policies: Store device ID with device token... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 5 #include <string>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "chrome/browser/browser_thread.h" 10 #include "chrome/browser/browser_thread.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 }; 78 };
79 79
80 TEST_F(DeviceTokenFetcherTest, IsPending) { 80 TEST_F(DeviceTokenFetcherTest, IsPending) {
81 ASSERT_TRUE(fetcher_->IsTokenPending()); 81 ASSERT_TRUE(fetcher_->IsTokenPending());
82 backend_->AllShouldSucceed(); 82 backend_->AllShouldSucceed();
83 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1); 83 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
84 SimulateSuccessfulLoginAndRunPending(); 84 SimulateSuccessfulLoginAndRunPending();
85 ASSERT_FALSE(fetcher_->IsTokenPending()); 85 ASSERT_FALSE(fetcher_->IsTokenPending());
86 } 86 }
87 87
88 TEST_F(DeviceTokenFetcherTest, StoreAndLoad) {
89 backend_->AllShouldSucceed();
90 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
91 SimulateSuccessfulLoginAndRunPending();
92 ASSERT_FALSE(fetcher_->IsTokenPending());
93 std::string device_token = fetcher_->GetDeviceToken();
94 std::string device_id = fetcher_->GetDeviceID();
95 ASSERT_NE("", device_id);
96
97 FilePath token_path;
98 GetDeviceTokenPath(fetcher_, &token_path);
99 scoped_refptr<DeviceTokenFetcher> fetcher2(
100 new DeviceTokenFetcher(backend_.get(), token_path));
101 fetcher2->StartFetching();
102 loop_.RunAllPending();
103 ASSERT_EQ(device_id, fetcher2->GetDeviceID());
104 ASSERT_EQ(device_token, fetcher2->GetDeviceToken());
105 }
106
107 TEST_F(DeviceTokenFetcherTest, SimpleFetchSingleLogin) { 88 TEST_F(DeviceTokenFetcherTest, SimpleFetchSingleLogin) {
108 backend_->AllShouldSucceed(); 89 backend_->AllShouldSucceed();
109 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1); 90 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
110 SimulateSuccessfulLoginAndRunPending(); 91 SimulateSuccessfulLoginAndRunPending();
111 ASSERT_FALSE(fetcher_->IsTokenPending()); 92 ASSERT_FALSE(fetcher_->IsTokenPending());
112 ASSERT_TRUE(fetcher_->IsTokenValid()); 93 ASSERT_TRUE(fetcher_->IsTokenValid());
113 const std::string token(fetcher_->GetDeviceToken()); 94 const std::string token(fetcher_->GetDeviceToken());
114 EXPECT_NE("", token); 95 EXPECT_NE("", token);
115 } 96 }
116 97
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 TEST_F(DeviceTokenFetcherTest, FailedServerRequest) { 141 TEST_F(DeviceTokenFetcherTest, FailedServerRequest) {
161 backend_->AllShouldFail(); 142 backend_->AllShouldFail();
162 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1); 143 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).Times(1);
163 SimulateSuccessfulLoginAndRunPending(); 144 SimulateSuccessfulLoginAndRunPending();
164 ASSERT_FALSE(fetcher_->IsTokenPending()); 145 ASSERT_FALSE(fetcher_->IsTokenPending());
165 const std::string token(fetcher_->GetDeviceToken()); 146 const std::string token(fetcher_->GetDeviceToken());
166 EXPECT_EQ("", token); 147 EXPECT_EQ("", token);
167 } 148 }
168 149
169 } // namespace policy 150 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_token_fetcher.cc ('k') | chrome/browser/policy/proto/device_management_local.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698