Commit fe031a23 authored by Sergey Abbakumov's avatar Sergey Abbakumov Committed by Commit Bot

Fix feature identity in Android tests

This CL fixes media_unittests in a component build.
The issue was a duplicate global feature object since media_switches.cc
is inside a source set.

Bug: 1123898
Change-Id: I97f18f166af4da4924ec191de6c183426e942aec
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2387578Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Commit-Queue: Sergey Abbakumov <sabbakumov@yandex-team.ru>
Cr-Commit-Position: refs/heads/master@{#804143}
parent a815b5a7
...@@ -115,6 +115,17 @@ bool VideoDecodeStatsDBImpl::GetEnableUnweightedEntries() { ...@@ -115,6 +115,17 @@ bool VideoDecodeStatsDBImpl::GetEnableUnweightedEntries() {
kEnableUnweightedEntriesDefault); kEnableUnweightedEntriesDefault);
} }
// static
base::FieldTrialParams VideoDecodeStatsDBImpl::GetFieldTrialParams() {
base::FieldTrialParams actual_trial_params;
const bool result = base::GetFieldTrialParamsByFeature(
kMediaCapabilitiesWithParameters, &actual_trial_params);
DCHECK(result);
return actual_trial_params;
}
// static // static
std::unique_ptr<VideoDecodeStatsDBImpl> VideoDecodeStatsDBImpl::Create( std::unique_ptr<VideoDecodeStatsDBImpl> VideoDecodeStatsDBImpl::Create(
base::FilePath db_dir, base::FilePath db_dir,
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/metrics/field_trial_params.h"
#include "components/leveldb_proto/public/proto_database.h" #include "components/leveldb_proto/public/proto_database.h"
#include "media/base/media_export.h" #include "media/base/media_export.h"
#include "media/base/video_codecs.h" #include "media/base/video_codecs.h"
...@@ -86,6 +87,9 @@ class MEDIA_EXPORT VideoDecodeStatsDBImpl : public VideoDecodeStatsDB { ...@@ -86,6 +87,9 @@ class MEDIA_EXPORT VideoDecodeStatsDBImpl : public VideoDecodeStatsDB {
// regardless of how many frames were decoded. // regardless of how many frames were decoded.
static bool GetEnableUnweightedEntries(); static bool GetEnableUnweightedEntries();
// Returns current feature params.
static base::FieldTrialParams GetFieldTrialParams();
// Creates a PendingOperation using |uma_str| and adds it to |pending_ops_| // Creates a PendingOperation using |uma_str| and adds it to |pending_ops_|
// map. Returns PendingOpId for newly started operation. Callers must later // map. Returns PendingOpId for newly started operation. Callers must later
// call CompletePendingOp() with this id to destroy the PendingOperation and // call CompletePendingOp() with this id to destroy the PendingOperation and
......
...@@ -91,6 +91,10 @@ class VideoDecodeStatsDBImplTest : public ::testing::Test { ...@@ -91,6 +91,10 @@ class VideoDecodeStatsDBImplTest : public ::testing::Test {
return VideoDecodeStatsDBImpl::GetEnableUnweightedEntries(); return VideoDecodeStatsDBImpl::GetEnableUnweightedEntries();
} }
static base::FieldTrialParams GetFieldTrialParams() {
return VideoDecodeStatsDBImpl::GetFieldTrialParams();
}
void SetDBClock(base::Clock* clock) { void SetDBClock(base::Clock* clock) {
stats_db_->set_wall_clock_for_test(clock); stats_db_->set_wall_clock_for_test(clock);
} }
...@@ -273,10 +277,7 @@ TEST_F(VideoDecodeStatsDBImplTest, ConfigureMaxFramesPerBuffer) { ...@@ -273,10 +277,7 @@ TEST_F(VideoDecodeStatsDBImplTest, ConfigureMaxFramesPerBuffer) {
scoped_feature_list.InitAndEnableFeatureWithParameters( scoped_feature_list.InitAndEnableFeatureWithParameters(
media::kMediaCapabilitiesWithParameters, params); media::kMediaCapabilitiesWithParameters, params);
base::FieldTrialParams actual_params; EXPECT_EQ(GetFieldTrialParams(), params);
EXPECT_TRUE(base::GetFieldTrialParamsByFeature(
media::kMediaCapabilitiesWithParameters, &actual_params));
EXPECT_EQ(params, actual_params);
EXPECT_EQ(new_max_frames_per_buffer, GetMaxFramesPerBuffer()); EXPECT_EQ(new_max_frames_per_buffer, GetMaxFramesPerBuffer());
...@@ -314,10 +315,7 @@ TEST_F(VideoDecodeStatsDBImplTest, ConfigureExpireDays) { ...@@ -314,10 +315,7 @@ TEST_F(VideoDecodeStatsDBImplTest, ConfigureExpireDays) {
scoped_feature_list.InitAndEnableFeatureWithParameters( scoped_feature_list.InitAndEnableFeatureWithParameters(
media::kMediaCapabilitiesWithParameters, params); media::kMediaCapabilitiesWithParameters, params);
base::FieldTrialParams actual_params; EXPECT_EQ(GetFieldTrialParams(), params);
EXPECT_TRUE(base::GetFieldTrialParamsByFeature(
media::kMediaCapabilitiesWithParameters, &actual_params));
EXPECT_EQ(params, actual_params);
EXPECT_EQ(new_max_days_to_keep_stats, GetMaxDaysToKeepStats()); EXPECT_EQ(new_max_days_to_keep_stats, GetMaxDaysToKeepStats());
...@@ -638,10 +636,7 @@ TEST_F(VideoDecodeStatsDBImplTest, EnableUnweightedEntries) { ...@@ -638,10 +636,7 @@ TEST_F(VideoDecodeStatsDBImplTest, EnableUnweightedEntries) {
scoped_feature_list.InitAndEnableFeatureWithParameters( scoped_feature_list.InitAndEnableFeatureWithParameters(
media::kMediaCapabilitiesWithParameters, params); media::kMediaCapabilitiesWithParameters, params);
base::FieldTrialParams actual_params; EXPECT_EQ(GetFieldTrialParams(), params);
EXPECT_TRUE(base::GetFieldTrialParamsByFeature(
media::kMediaCapabilitiesWithParameters, &actual_params));
EXPECT_EQ(params, actual_params);
// Confirm field trial overridden. // Confirm field trial overridden.
EXPECT_TRUE(GetMaxDaysToKeepStats()); EXPECT_TRUE(GetMaxDaysToKeepStats());
......
...@@ -54,6 +54,17 @@ double VideoDecodePerfHistory::GetMaxSmoothDroppedFramesPercent(bool is_eme) { ...@@ -54,6 +54,17 @@ double VideoDecodePerfHistory::GetMaxSmoothDroppedFramesPercent(bool is_eme) {
return threshold; return threshold;
} }
// static
base::FieldTrialParams VideoDecodePerfHistory::GetFieldTrialParams() {
base::FieldTrialParams actual_trial_params;
const bool result = base::GetFieldTrialParamsByFeature(
kMediaCapabilitiesWithParameters, &actual_trial_params);
DCHECK(result);
return actual_trial_params;
}
VideoDecodePerfHistory::VideoDecodePerfHistory( VideoDecodePerfHistory::VideoDecodePerfHistory(
std::unique_ptr<VideoDecodeStatsDB> db, std::unique_ptr<VideoDecodeStatsDB> db,
learning::FeatureProviderFactoryCB feature_factory_cb) learning::FeatureProviderFactoryCB feature_factory_cb)
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <string> #include <string>
#include "base/callback.h" #include "base/callback.h"
#include "base/metrics/field_trial_params.h"
#include "base/sequence_checker.h" #include "base/sequence_checker.h"
#include "base/supports_user_data.h" #include "base/supports_user_data.h"
#include "media/base/video_codecs.h" #include "media/base/video_codecs.h"
...@@ -100,6 +101,9 @@ class MEDIA_MOJO_EXPORT VideoDecodePerfHistory ...@@ -100,6 +101,9 @@ class MEDIA_MOJO_EXPORT VideoDecodePerfHistory
// of dropped frames is less-than-or-equal-to this value. // of dropped frames is less-than-or-equal-to this value.
static double GetMaxSmoothDroppedFramesPercent(bool is_eme); static double GetMaxSmoothDroppedFramesPercent(bool is_eme);
// Returns current feature params.
static base::FieldTrialParams GetFieldTrialParams();
// Track the status of database lazy initialization. // Track the status of database lazy initialization.
enum InitStatus { enum InitStatus {
UNINITIALIZED, UNINITIALIZED,
......
...@@ -172,6 +172,10 @@ class VideoDecodePerfHistoryTest : public testing::Test { ...@@ -172,6 +172,10 @@ class VideoDecodePerfHistoryTest : public testing::Test {
return VideoDecodePerfHistory::GetMaxSmoothDroppedFramesPercent(is_eme); return VideoDecodePerfHistory::GetMaxSmoothDroppedFramesPercent(is_eme);
} }
static base::FieldTrialParams GetFieldTrialParams() {
return VideoDecodePerfHistory::GetFieldTrialParams();
}
// Tests may set this as the callback for VideoDecodePerfHistory::GetPerfInfo // Tests may set this as the callback for VideoDecodePerfHistory::GetPerfInfo
// to check the results of the call. // to check the results of the call.
MOCK_METHOD2(MockGetPerfInfoCB, MOCK_METHOD2(MockGetPerfInfoCB,
...@@ -822,10 +826,7 @@ TEST_P(VideoDecodePerfHistoryParamTest, ...@@ -822,10 +826,7 @@ TEST_P(VideoDecodePerfHistoryParamTest,
scoped_feature_list.InitAndEnableFeatureWithParameters( scoped_feature_list.InitAndEnableFeatureWithParameters(
media::kMediaCapabilitiesWithParameters, trial_params); media::kMediaCapabilitiesWithParameters, trial_params);
base::FieldTrialParams actual_trial_params; EXPECT_EQ(GetFieldTrialParams(), trial_params);
EXPECT_TRUE(base::GetFieldTrialParamsByFeature(
media::kMediaCapabilitiesWithParameters, &actual_trial_params));
EXPECT_EQ(trial_params, actual_trial_params);
// Non EME threshold is overridden. // Non EME threshold is overridden.
EXPECT_EQ(new_smooth_dropped_frames_threshold, EXPECT_EQ(new_smooth_dropped_frames_threshold,
...@@ -940,10 +941,7 @@ TEST_P(VideoDecodePerfHistoryParamTest, ...@@ -940,10 +941,7 @@ TEST_P(VideoDecodePerfHistoryParamTest,
scoped_feature_list.InitAndEnableFeatureWithParameters( scoped_feature_list.InitAndEnableFeatureWithParameters(
media::kMediaCapabilitiesWithParameters, trial_params); media::kMediaCapabilitiesWithParameters, trial_params);
base::FieldTrialParams actual_trial_params; EXPECT_EQ(GetFieldTrialParams(), trial_params);
EXPECT_TRUE(base::GetFieldTrialParamsByFeature(
media::kMediaCapabilitiesWithParameters, &actual_trial_params));
EXPECT_EQ(trial_params, actual_trial_params);
// Both thresholds should be overridden. // Both thresholds should be overridden.
EXPECT_EQ(new_CLEAR_smooth_dropped_frames_threshold, EXPECT_EQ(new_CLEAR_smooth_dropped_frames_threshold,
...@@ -1084,4 +1082,4 @@ TEST_F(VideoDecodePerfHistoryTest, ClearHistoryTriggersFailedInitialize) { ...@@ -1084,4 +1082,4 @@ TEST_F(VideoDecodePerfHistoryTest, ClearHistoryTriggersFailedInitialize) {
task_environment_.RunUntilIdle(); task_environment_.RunUntilIdle();
} }
} // namespace media } // namespace media
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment