1 // Copyright 2018 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 "chrome/browser/resource_coordinator/tab_ranker/tab_features_test_helper.h" 6 7 #include "chrome/browser/resource_coordinator/tab_ranker/tab_features.h" 8 9 namespace tab_ranker { 10 11 // The following two functions are used in multiple tests to make sure the 12 // conversion, logging and inferencing use the same group of features. 13 // Returns a default tab features with some field unset. GetPartialTabFeaturesForTesting()14TabFeatures GetPartialTabFeaturesForTesting() { 15 TabFeatures tab; 16 17 tab.has_before_unload_handler = true; 18 tab.has_form_entry = true; 19 tab.is_pinned = true; 20 tab.key_event_count = 121; 21 tab.mouse_event_count = 122; 22 tab.mru_index = 13; 23 tab.navigation_entry_count = 124; 24 tab.num_reactivations = 125; 25 tab.page_transition_from_address_bar = true; 26 tab.page_transition_is_redirect = true; 27 tab.time_from_backgrounded = 110000; 28 tab.total_tab_count = 130; 29 tab.touch_event_count = 128; 30 tab.was_recently_audible = true; 31 tab.window_is_active = true; 32 tab.window_show_state = 3; 33 tab.window_tab_count = 127; 34 tab.window_type = 4; 35 36 return tab; 37 } 38 39 // Returns a tab features with all field set. GetFullTabFeaturesForTesting()40TabFeatures GetFullTabFeaturesForTesting() { 41 TabFeatures tab; 42 43 tab.has_before_unload_handler = true; 44 tab.has_form_entry = true; 45 tab.is_pinned = true; 46 tab.key_event_count = 21; 47 tab.mouse_event_count = 22; 48 tab.mru_index = 27; 49 tab.navigation_entry_count = 24; 50 tab.num_reactivations = 25; 51 tab.page_transition_core_type = 2; 52 tab.page_transition_from_address_bar = true; 53 tab.page_transition_is_redirect = true; 54 tab.site_engagement_score = 26; 55 tab.time_from_backgrounded = 10000; 56 tab.total_tab_count = 30; 57 tab.touch_event_count = 28; 58 tab.was_recently_audible = true; 59 tab.window_is_active = true; 60 tab.window_show_state = 3; 61 tab.window_tab_count = 27; 62 tab.window_type = 4; 63 64 tab.host = "www.google.com"; 65 tab.frecency_score = 0.1234f; 66 return tab; 67 } 68 69 } // namespace tab_ranker 70