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

Side by Side Diff: components/machine_intelligence/ranker_model_unittest.cc

Issue 2925733002: Move ranker_model_loader to a new component. (Closed)
Patch Set: Adressing sdefresne's comments. Created 3 years, 5 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
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/translate/core/browser/ranker_model.h" 5 #include "components/machine_intelligence/ranker_model.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "components/translate/core/browser/proto/ranker_model.pb.h" 11 #include "components/machine_intelligence/proto/ranker_model.pb.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace { 14 namespace {
15 15
16 using chrome_intelligence::RankerModel; 16 using machine_intelligence::RankerModel;
17 17
18 const char kModelURL[] = "https://some.url.net/model"; 18 const char kModelURL[] = "https://some.url.net/model";
19 19
20 int64_t InSeconds(const base::Time t) { 20 int64_t InSeconds(const base::Time t) {
21 return (t - base::Time()).InSeconds(); 21 return (t - base::Time()).InSeconds();
22 } 22 }
23 23
24 std::unique_ptr<RankerModel> NewModel(const std::string& model_url, 24 std::unique_ptr<RankerModel> NewModel(const std::string& model_url,
25 base::Time last_modified, 25 base::Time last_modified,
26 base::TimeDelta cache_duration) { 26 base::TimeDelta cache_duration) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 TEST(RankerModelTest, IsExpired) { 67 TEST(RankerModelTest, IsExpired) {
68 base::Time today = base::Time::Now(); 68 base::Time today = base::Time::Now();
69 base::TimeDelta days_15 = base::TimeDelta::FromDays(15); 69 base::TimeDelta days_15 = base::TimeDelta::FromDays(15);
70 base::TimeDelta days_30 = base::TimeDelta::FromDays(30); 70 base::TimeDelta days_30 = base::TimeDelta::FromDays(30);
71 base::TimeDelta days_60 = base::TimeDelta::FromDays(60); 71 base::TimeDelta days_60 = base::TimeDelta::FromDays(60);
72 72
73 EXPECT_FALSE(NewModel(kModelURL, today, days_30)->IsExpired()); 73 EXPECT_FALSE(NewModel(kModelURL, today, days_30)->IsExpired());
74 EXPECT_FALSE(NewModel(kModelURL, today - days_15, days_30)->IsExpired()); 74 EXPECT_FALSE(NewModel(kModelURL, today - days_15, days_30)->IsExpired());
75 EXPECT_TRUE(NewModel(kModelURL, today - days_60, days_30)->IsExpired()); 75 EXPECT_TRUE(NewModel(kModelURL, today - days_60, days_30)->IsExpired());
76 } 76 }
OLDNEW
« no previous file with comments | « components/machine_intelligence/ranker_model_loader_unittest.cc ('k') | components/machine_intelligence/ranker_url_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698