Merge "Refactor some ViewHolder complications." into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
e339737dab
@@ -16,32 +16,32 @@
|
||||
|
||||
package com.android.systemui.dreams.complication;
|
||||
|
||||
import static com.android.systemui.dreams.complication.dagger.DreamClockDateComplicationComponent.DreamClockDateComplicationModule.DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS;
|
||||
import static com.android.systemui.dreams.complication.dagger.DreamClockDateComplicationComponent.DreamClockDateComplicationModule.DREAM_CLOCK_DATE_COMPLICATION_VIEW;
|
||||
import static com.android.systemui.dreams.complication.dagger.DreamClockDateComplicationModule.DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS;
|
||||
import static com.android.systemui.dreams.complication.dagger.DreamClockDateComplicationModule.DREAM_CLOCK_DATE_COMPLICATION_VIEW;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.systemui.CoreStartable;
|
||||
import com.android.systemui.dreams.DreamOverlayStateController;
|
||||
import com.android.systemui.dreams.complication.dagger.DreamClockDateComplicationComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
|
||||
/**
|
||||
* Clock Date Complication that produce Clock Date view holder.
|
||||
*/
|
||||
public class DreamClockDateComplication implements Complication {
|
||||
DreamClockDateComplicationComponent.Factory mComponentFactory;
|
||||
private final Provider<DreamClockDateViewHolder> mDreamClockDateViewHolderProvider;
|
||||
|
||||
/**
|
||||
* Default constructor for {@link DreamClockDateComplication}.
|
||||
*/
|
||||
@Inject
|
||||
public DreamClockDateComplication(
|
||||
DreamClockDateComplicationComponent.Factory componentFactory) {
|
||||
mComponentFactory = componentFactory;
|
||||
Provider<DreamClockDateViewHolder> dreamClockDateViewHolderProvider) {
|
||||
mDreamClockDateViewHolderProvider = dreamClockDateViewHolderProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,11 +54,11 @@ public class DreamClockDateComplication implements Complication {
|
||||
*/
|
||||
@Override
|
||||
public ViewHolder createView(ComplicationViewModel model) {
|
||||
return mComponentFactory.create().getViewHolder();
|
||||
return mDreamClockDateViewHolderProvider.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link CoreStartable} responsbile for registering {@link DreamClockDateComplication} with
|
||||
* {@link CoreStartable} responsible for registering {@link DreamClockDateComplication} with
|
||||
* SystemUI.
|
||||
*/
|
||||
public static class Registrant extends CoreStartable {
|
||||
@@ -84,7 +84,7 @@ public class DreamClockDateComplication implements Complication {
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewHolder to contain value/logic associated with a Clock Date Complication View.
|
||||
* {@link ViewHolder} to contain value/logic associated with {@link DreamClockDateComplication}.
|
||||
*/
|
||||
public static class DreamClockDateViewHolder implements ViewHolder {
|
||||
private final View mView;
|
||||
|
||||
@@ -16,32 +16,32 @@
|
||||
|
||||
package com.android.systemui.dreams.complication;
|
||||
|
||||
import static com.android.systemui.dreams.complication.dagger.DreamClockTimeComplicationComponent.DreamClockTimeComplicationModule.DREAM_CLOCK_TIME_COMPLICATION_LAYOUT_PARAMS;
|
||||
import static com.android.systemui.dreams.complication.dagger.DreamClockTimeComplicationComponent.DreamClockTimeComplicationModule.DREAM_CLOCK_TIME_COMPLICATION_VIEW;
|
||||
import static com.android.systemui.dreams.complication.dagger.DreamClockTimeComplicationModule.DREAM_CLOCK_TIME_COMPLICATION_LAYOUT_PARAMS;
|
||||
import static com.android.systemui.dreams.complication.dagger.DreamClockTimeComplicationModule.DREAM_CLOCK_TIME_COMPLICATION_VIEW;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.systemui.CoreStartable;
|
||||
import com.android.systemui.dreams.DreamOverlayStateController;
|
||||
import com.android.systemui.dreams.complication.dagger.DreamClockTimeComplicationComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Provider;
|
||||
|
||||
/**
|
||||
* Clock Time Complication that produce Clock Time view holder.
|
||||
*/
|
||||
public class DreamClockTimeComplication implements Complication {
|
||||
DreamClockTimeComplicationComponent.Factory mComponentFactory;
|
||||
private final Provider<DreamClockTimeViewHolder> mDreamClockTimeViewHolderProvider;
|
||||
|
||||
/**
|
||||
* Default constructor for {@link DreamClockTimeComplication}.
|
||||
*/
|
||||
@Inject
|
||||
public DreamClockTimeComplication(
|
||||
DreamClockTimeComplicationComponent.Factory componentFactory) {
|
||||
mComponentFactory = componentFactory;
|
||||
Provider<DreamClockTimeViewHolder> dreamClockTimeViewHolderProvider) {
|
||||
mDreamClockTimeViewHolderProvider = dreamClockTimeViewHolderProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,11 +54,11 @@ public class DreamClockTimeComplication implements Complication {
|
||||
*/
|
||||
@Override
|
||||
public ViewHolder createView(ComplicationViewModel model) {
|
||||
return mComponentFactory.create().getViewHolder();
|
||||
return mDreamClockTimeViewHolderProvider.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link CoreStartable} responsbile for registering {@link DreamClockTimeComplication} with
|
||||
* {@link CoreStartable} responsible for registering {@link DreamClockTimeComplication} with
|
||||
* SystemUI.
|
||||
*/
|
||||
public static class Registrant extends CoreStartable {
|
||||
@@ -84,7 +84,7 @@ public class DreamClockTimeComplication implements Complication {
|
||||
}
|
||||
|
||||
/**
|
||||
* ViewHolder to contain value/logic associated with a Clock Time Complication View.
|
||||
* {@link ViewHolder} to contain value/logic associated with {@link DreamClockTimeComplication}.
|
||||
*/
|
||||
public static class DreamClockTimeViewHolder implements ViewHolder {
|
||||
private final View mView;
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.dreams.complication.dagger;
|
||||
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dreams.complication.ComplicationLayoutParams;
|
||||
import com.android.systemui.dreams.complication.DreamClockDateComplication.DreamClockDateViewHolder;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Scope;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import dagger.Subcomponent;
|
||||
|
||||
/**
|
||||
* {@link DreamClockDateComplicationComponent} is responsible for generating dependencies
|
||||
* surrounding the
|
||||
* Clock Date {@link com.android.systemui.dreams.complication.Complication}, such as the layout
|
||||
* details.
|
||||
*/
|
||||
@Subcomponent(modules = {
|
||||
DreamClockDateComplicationComponent.DreamClockDateComplicationModule.class,
|
||||
})
|
||||
@DreamClockDateComplicationComponent.DreamClockDateComplicationScope
|
||||
public interface DreamClockDateComplicationComponent {
|
||||
/**
|
||||
* Creates {@link DreamClockDateViewHolder}.
|
||||
*/
|
||||
DreamClockDateViewHolder getViewHolder();
|
||||
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Scope
|
||||
@interface DreamClockDateComplicationScope {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates {@link DreamClockDateComplicationComponent}.
|
||||
*/
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
DreamClockDateComplicationComponent create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scoped values for {@link DreamClockDateComplicationComponent}.
|
||||
*/
|
||||
@Module
|
||||
interface DreamClockDateComplicationModule {
|
||||
String DREAM_CLOCK_DATE_COMPLICATION_VIEW = "clock_date_complication_view";
|
||||
String DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS =
|
||||
"clock_date_complication_layout_params";
|
||||
// Order weight of insert into parent container
|
||||
int INSERT_ORDER_WEIGHT = 2;
|
||||
|
||||
/**
|
||||
* Provides the complication view.
|
||||
*/
|
||||
@Provides
|
||||
@DreamClockDateComplicationScope
|
||||
@Named(DREAM_CLOCK_DATE_COMPLICATION_VIEW)
|
||||
static View provideComplicationView(LayoutInflater layoutInflater) {
|
||||
return Preconditions.checkNotNull(
|
||||
layoutInflater.inflate(R.layout.dream_overlay_complication_clock_date,
|
||||
null, false),
|
||||
"R.layout.dream_overlay_complication_clock_date did not properly inflated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the layout parameters for the complication view.
|
||||
*/
|
||||
@Provides
|
||||
@DreamClockDateComplicationScope
|
||||
@Named(DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS)
|
||||
static ComplicationLayoutParams provideLayoutParams() {
|
||||
return new ComplicationLayoutParams(0,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ComplicationLayoutParams.POSITION_BOTTOM
|
||||
| ComplicationLayoutParams.POSITION_START,
|
||||
ComplicationLayoutParams.DIRECTION_END,
|
||||
INSERT_ORDER_WEIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.dreams.complication.dagger;
|
||||
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dreams.complication.ComplicationLayoutParams;
|
||||
import com.android.systemui.dreams.complication.DreamClockDateComplication;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/**
|
||||
* Module for providing {@link DreamClockDateComplication}.
|
||||
*/
|
||||
@Module
|
||||
public interface DreamClockDateComplicationModule {
|
||||
String DREAM_CLOCK_DATE_COMPLICATION_VIEW = "clock_date_complication_view";
|
||||
String DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS =
|
||||
"clock_date_complication_layout_params";
|
||||
// Order weight of insert into parent container
|
||||
//TODO(b/217199227): move to a single location.
|
||||
int INSERT_ORDER_WEIGHT = 2;
|
||||
|
||||
/**
|
||||
* Provides the complication view.
|
||||
*/
|
||||
@Provides
|
||||
@Named(DREAM_CLOCK_DATE_COMPLICATION_VIEW)
|
||||
static View provideComplicationView(LayoutInflater layoutInflater) {
|
||||
return Preconditions.checkNotNull(
|
||||
layoutInflater.inflate(R.layout.dream_overlay_complication_clock_date,
|
||||
null, false),
|
||||
"R.layout.dream_overlay_complication_clock_date did not properly inflated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the layout parameters for the complication view.
|
||||
*/
|
||||
@Provides
|
||||
@Named(DREAM_CLOCK_DATE_COMPLICATION_LAYOUT_PARAMS)
|
||||
static ComplicationLayoutParams provideLayoutParams() {
|
||||
return new ComplicationLayoutParams(0,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ComplicationLayoutParams.POSITION_BOTTOM
|
||||
| ComplicationLayoutParams.POSITION_START,
|
||||
ComplicationLayoutParams.DIRECTION_END,
|
||||
INSERT_ORDER_WEIGHT);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.dreams.complication.dagger;
|
||||
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextClock;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dreams.complication.ComplicationLayoutParams;
|
||||
import com.android.systemui.dreams.complication.DreamClockTimeComplication.DreamClockTimeViewHolder;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Scope;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import dagger.Subcomponent;
|
||||
|
||||
/**
|
||||
* {@link DreamClockTimeComplicationComponent} is responsible for generating dependencies
|
||||
* surrounding the
|
||||
* Clock Time {@link com.android.systemui.dreams.complication.Complication}, such as the layout
|
||||
* details.
|
||||
*/
|
||||
@Subcomponent(modules = {
|
||||
DreamClockTimeComplicationComponent.DreamClockTimeComplicationModule.class,
|
||||
})
|
||||
@DreamClockTimeComplicationComponent.DreamClockTimeComplicationScope
|
||||
public interface DreamClockTimeComplicationComponent {
|
||||
/**
|
||||
* Creates {@link DreamClockTimeViewHolder}.
|
||||
*/
|
||||
DreamClockTimeViewHolder getViewHolder();
|
||||
|
||||
@Documented
|
||||
@Retention(RUNTIME)
|
||||
@Scope
|
||||
@interface DreamClockTimeComplicationScope {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates {@link DreamClockTimeComplicationComponent}.
|
||||
*/
|
||||
@Subcomponent.Factory
|
||||
interface Factory {
|
||||
DreamClockTimeComplicationComponent create();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scoped values for {@link DreamClockTimeComplicationComponent}.
|
||||
*/
|
||||
@Module
|
||||
interface DreamClockTimeComplicationModule {
|
||||
String DREAM_CLOCK_TIME_COMPLICATION_VIEW = "clock_time_complication_view";
|
||||
String DREAM_CLOCK_TIME_COMPLICATION_LAYOUT_PARAMS =
|
||||
"clock_time_complication_layout_params";
|
||||
// Order weight of insert into parent container
|
||||
int INSERT_ORDER_WEIGHT = 0;
|
||||
String TAG_WEIGHT = "'wght' ";
|
||||
int WEIGHT = 200;
|
||||
|
||||
/**
|
||||
* Provides the complication view.
|
||||
*/
|
||||
@Provides
|
||||
@DreamClockTimeComplicationScope
|
||||
@Named(DREAM_CLOCK_TIME_COMPLICATION_VIEW)
|
||||
static View provideComplicationView(LayoutInflater layoutInflater) {
|
||||
final TextClock view = Preconditions.checkNotNull((TextClock)
|
||||
layoutInflater.inflate(R.layout.dream_overlay_complication_clock_time,
|
||||
null, false),
|
||||
"R.layout.dream_overlay_complication_clock_time did not properly inflated");
|
||||
view.setFontVariationSettings(TAG_WEIGHT + WEIGHT);
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the layout parameters for the complication view.
|
||||
*/
|
||||
@Provides
|
||||
@DreamClockTimeComplicationScope
|
||||
@Named(DREAM_CLOCK_TIME_COMPLICATION_LAYOUT_PARAMS)
|
||||
static ComplicationLayoutParams provideLayoutParams() {
|
||||
return new ComplicationLayoutParams(0,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ComplicationLayoutParams.POSITION_BOTTOM
|
||||
| ComplicationLayoutParams.POSITION_START,
|
||||
ComplicationLayoutParams.DIRECTION_UP,
|
||||
INSERT_ORDER_WEIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2022 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.systemui.dreams.complication.dagger;
|
||||
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextClock;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.dreams.complication.ComplicationLayoutParams;
|
||||
import com.android.systemui.dreams.complication.DreamClockTimeComplication;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
/**
|
||||
* Module for providing {@link DreamClockTimeComplication}.
|
||||
*/
|
||||
@Module
|
||||
public interface DreamClockTimeComplicationModule {
|
||||
String DREAM_CLOCK_TIME_COMPLICATION_VIEW = "clock_time_complication_view";
|
||||
String DREAM_CLOCK_TIME_COMPLICATION_LAYOUT_PARAMS =
|
||||
"clock_time_complication_layout_params";
|
||||
// Order weight of insert into parent container
|
||||
//TODO(b/217199227): move to a single location.
|
||||
int INSERT_ORDER_WEIGHT = 0;
|
||||
String TAG_WEIGHT = "'wght' ";
|
||||
int WEIGHT = 200;
|
||||
|
||||
/**
|
||||
* Provides the complication view.
|
||||
*/
|
||||
@Provides
|
||||
@Named(DREAM_CLOCK_TIME_COMPLICATION_VIEW)
|
||||
static View provideComplicationView(LayoutInflater layoutInflater) {
|
||||
final TextClock view = Preconditions.checkNotNull((TextClock)
|
||||
layoutInflater.inflate(R.layout.dream_overlay_complication_clock_time,
|
||||
null, false),
|
||||
"R.layout.dream_overlay_complication_clock_time did not properly inflated");
|
||||
view.setFontVariationSettings(TAG_WEIGHT + WEIGHT);
|
||||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the layout parameters for the complication view.
|
||||
*/
|
||||
@Provides
|
||||
@Named(DREAM_CLOCK_TIME_COMPLICATION_LAYOUT_PARAMS)
|
||||
static ComplicationLayoutParams provideLayoutParams() {
|
||||
return new ComplicationLayoutParams(0,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ComplicationLayoutParams.POSITION_BOTTOM
|
||||
| ComplicationLayoutParams.POSITION_START,
|
||||
ComplicationLayoutParams.DIRECTION_UP,
|
||||
INSERT_ORDER_WEIGHT);
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,12 @@ import dagger.Module;
|
||||
* Module for all components with corresponding dream layer complications registered in
|
||||
* {@link SystemUIBinder}.
|
||||
*/
|
||||
@Module(subcomponents = {
|
||||
DreamClockTimeComplicationComponent.class,
|
||||
DreamClockDateComplicationComponent.class,
|
||||
DreamWeatherComplicationComponent.class,
|
||||
})
|
||||
@Module(includes = {
|
||||
DreamClockDateComplicationModule.class,
|
||||
DreamClockTimeComplicationModule.class,
|
||||
},
|
||||
subcomponents = {
|
||||
DreamWeatherComplicationComponent.class,
|
||||
})
|
||||
public interface RegisteredComplicationsModule {
|
||||
}
|
||||
|
||||
@@ -15,11 +15,16 @@
|
||||
*/
|
||||
package com.android.systemui.dreams.complication;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
@@ -32,6 +37,8 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
public class DreamClockDateComplicationTest extends SysuiTestCase {
|
||||
@@ -45,9 +52,28 @@ public class DreamClockDateComplicationTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private DreamClockDateComplication mComplication;
|
||||
|
||||
@Mock
|
||||
private Provider<DreamClockDateComplication.DreamClockDateViewHolder>
|
||||
mDreamClockDateViewHolderProvider;
|
||||
|
||||
@Mock
|
||||
private DreamClockDateComplication.DreamClockDateViewHolder
|
||||
mDreamClockDateViewHolder;
|
||||
|
||||
@Mock
|
||||
private ComplicationViewModel mComplicationViewModel;
|
||||
|
||||
@Mock
|
||||
private View mView;
|
||||
|
||||
@Mock
|
||||
private ComplicationLayoutParams mLayoutParams;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mDreamClockDateViewHolderProvider.get()).thenReturn(mDreamClockDateViewHolder);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,4 +89,40 @@ public class DreamClockDateComplicationTest extends SysuiTestCase {
|
||||
registrant.start();
|
||||
verify(mDreamOverlayStateController).addComplication(eq(mComplication));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies {@link DreamClockDateComplication} has the required type.
|
||||
*/
|
||||
@Test
|
||||
public void testComplicationRequiredTypeAvailability() {
|
||||
final DreamClockDateComplication complication =
|
||||
new DreamClockDateComplication(mDreamClockDateViewHolderProvider);
|
||||
assertEquals(Complication.COMPLICATION_TYPE_DATE,
|
||||
complication.getRequiredTypeAvailability());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies {@link DreamClockDateComplication.DreamClockDateViewHolder} is obtainable from its
|
||||
* provider when the complication creates view.
|
||||
*/
|
||||
@Test
|
||||
public void testComplicationViewHolderProviderOnCreateView() {
|
||||
final DreamClockDateComplication complication =
|
||||
new DreamClockDateComplication(mDreamClockDateViewHolderProvider);
|
||||
final Complication.ViewHolder viewHolder = complication.createView(mComplicationViewModel);
|
||||
verify(mDreamClockDateViewHolderProvider).get();
|
||||
assertThat(viewHolder).isEqualTo(mDreamClockDateViewHolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies {@link DreamClockDateComplication.DreamClockDateViewHolder} has the intended view
|
||||
* and layout parameters from constructor.
|
||||
*/
|
||||
@Test
|
||||
public void testComplicationViewHolderContentAccessors() {
|
||||
final DreamClockDateComplication.DreamClockDateViewHolder viewHolder =
|
||||
new DreamClockDateComplication.DreamClockDateViewHolder(mView, mLayoutParams);
|
||||
assertThat(viewHolder.getView()).isEqualTo(mView);
|
||||
assertThat(viewHolder.getLayoutParams()).isEqualTo(mLayoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,16 @@
|
||||
*/
|
||||
package com.android.systemui.dreams.complication;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.testing.AndroidTestingRunner;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
@@ -32,6 +37,8 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
public class DreamClockTimeComplicationTest extends SysuiTestCase {
|
||||
@@ -45,9 +52,27 @@ public class DreamClockTimeComplicationTest extends SysuiTestCase {
|
||||
@Mock
|
||||
private DreamClockTimeComplication mComplication;
|
||||
|
||||
@Mock
|
||||
private Provider<DreamClockTimeComplication.DreamClockTimeViewHolder>
|
||||
mDreamClockTimeViewHolderProvider;
|
||||
|
||||
@Mock
|
||||
private DreamClockTimeComplication.DreamClockTimeViewHolder
|
||||
mDreamClockTimeViewHolder;
|
||||
|
||||
@Mock
|
||||
private ComplicationViewModel mComplicationViewModel;
|
||||
|
||||
@Mock
|
||||
private View mView;
|
||||
|
||||
@Mock
|
||||
private ComplicationLayoutParams mLayoutParams;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mDreamClockTimeViewHolderProvider.get()).thenReturn(mDreamClockTimeViewHolder);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,4 +88,40 @@ public class DreamClockTimeComplicationTest extends SysuiTestCase {
|
||||
registrant.start();
|
||||
verify(mDreamOverlayStateController).addComplication(eq(mComplication));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies {@link DreamClockTimeComplication} has the required type.
|
||||
*/
|
||||
@Test
|
||||
public void testComplicationRequiredTypeAvailability() {
|
||||
final DreamClockTimeComplication complication =
|
||||
new DreamClockTimeComplication(mDreamClockTimeViewHolderProvider);
|
||||
assertEquals(Complication.COMPLICATION_TYPE_TIME,
|
||||
complication.getRequiredTypeAvailability());
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies {@link DreamClockTimeComplication.DreamClockTimeViewHolder} is obtainable from its
|
||||
* provider when the complication creates view.
|
||||
*/
|
||||
@Test
|
||||
public void testComplicationViewHolderProviderOnCreateView() {
|
||||
final DreamClockTimeComplication complication =
|
||||
new DreamClockTimeComplication(mDreamClockTimeViewHolderProvider);
|
||||
final Complication.ViewHolder viewHolder = complication.createView(mComplicationViewModel);
|
||||
verify(mDreamClockTimeViewHolderProvider).get();
|
||||
assertThat(viewHolder).isEqualTo(mDreamClockTimeViewHolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies {@link DreamClockTimeComplication.DreamClockTimeViewHolder} has the intended view
|
||||
* and layout parameters from constructor.
|
||||
*/
|
||||
@Test
|
||||
public void testComplicationViewHolderContentAccessors() {
|
||||
final DreamClockTimeComplication.DreamClockTimeViewHolder viewHolder =
|
||||
new DreamClockTimeComplication.DreamClockTimeViewHolder(mView, mLayoutParams);
|
||||
assertThat(viewHolder.getView()).isEqualTo(mView);
|
||||
assertThat(viewHolder.getLayoutParams()).isEqualTo(mLayoutParams);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user