Call HandleAction with logData if present on the element

PiperOrigin-RevId: 253059383
Change-Id: Ib5e000981962eb65bcccc33c5b258e55ec1614a8
diff --git a/src/main/java/com/google/android/libraries/feed/piet/ElementAdapter.java b/src/main/java/com/google/android/libraries/feed/piet/ElementAdapter.java
index 00e4c04..9324eef 100644
--- a/src/main/java/com/google/android/libraries/feed/piet/ElementAdapter.java
+++ b/src/main/java/com/google/android/libraries/feed/piet/ElementAdapter.java
@@ -345,12 +345,12 @@
     switch (baseElement.getActionsDataCase()) {
       case ACTIONS:
         actions = baseElement.getActions();
-        ViewUtils.setOnClickActions(actions, getBaseView(), frameContext);
+        ViewUtils.setOnClickActions(actions, getBaseView(), frameContext, baseElement.getLogData());
         break;
       case ACTIONS_BINDING:
         // Get the actions from the actions_binding in the template
         actions = frameContext.getActionsFromBinding(baseElement.getActionsBinding());
-        ViewUtils.setOnClickActions(actions, getBaseView(), frameContext);
+        ViewUtils.setOnClickActions(actions, getBaseView(), frameContext, baseElement.getLogData());
         break;
       default: // No actions defined.
         actions = Actions.getDefaultInstance();
diff --git a/src/main/java/com/google/android/libraries/feed/piet/ViewUtils.java b/src/main/java/com/google/android/libraries/feed/piet/ViewUtils.java
index cb82a80..be3ddf6 100644
--- a/src/main/java/com/google/android/libraries/feed/piet/ViewUtils.java
+++ b/src/main/java/com/google/android/libraries/feed/piet/ViewUtils.java
@@ -86,7 +86,8 @@
    * RippleDrawable is added to the foreground of the view, so that a ripple animation happens on
    * each click.
    */
-  static void setOnClickActions(Actions actions, View view, FrameContext frameContext) {
+  static void setOnClickActions(
+      Actions actions, View view, FrameContext frameContext, LogData logData) {
     ActionHandler handler = frameContext.getActionHandler();
     if (actions.hasOnLongClickAction()) {
       view.setOnLongClickListener(
@@ -96,7 +97,7 @@
                 ActionType.LONG_CLICK,
                 frameContext.getFrame(),
                 view,
-                LogData.getDefaultInstance());
+                logData);
             return true;
           });
     } else {
@@ -110,7 +111,7 @@
                 ActionType.CLICK,
                 frameContext.getFrame(),
                 view,
-                LogData.getDefaultInstance());
+                logData);
           });
     } else {
       clearOnClickActions(view);
diff --git a/src/test/java/com/google/android/libraries/feed/piet/ElementAdapterTest.java b/src/test/java/com/google/android/libraries/feed/piet/ElementAdapterTest.java
index 73f1c8e..e630f2f 100644
--- a/src/test/java/com/google/android/libraries/feed/piet/ElementAdapterTest.java
+++ b/src/test/java/com/google/android/libraries/feed/piet/ElementAdapterTest.java
@@ -149,7 +149,6 @@
   public void testGetters() {
     Element defaultElement =
         Element.newBuilder()
-            .setVed("VED")
             .setGravityHorizontal(GravityHorizontal.GRAVITY_CENTER)
             .build();
     Frame frame = Frame.newBuilder().setTag("FRAME").build();
diff --git a/src/test/java/com/google/android/libraries/feed/piet/ViewUtilsTest.java b/src/test/java/com/google/android/libraries/feed/piet/ViewUtilsTest.java
index b9591f4..5daa1e6 100644
--- a/src/test/java/com/google/android/libraries/feed/piet/ViewUtilsTest.java
+++ b/src/test/java/com/google/android/libraries/feed/piet/ViewUtilsTest.java
@@ -156,29 +156,31 @@
 
   @Test
   public void testSetOnClickActions_success() {
-    ViewUtils.setOnClickActions(DEFAULT_ACTIONS, view, mockFrameContext);
+    LogData logData = LogData.newBuilder().build();
+    ViewUtils.setOnClickActions(DEFAULT_ACTIONS, view, mockFrameContext, logData);
 
     assertThat(view.hasOnClickListeners()).isTrue();
 
     view.callOnClick();
     verify(mockActionHandler)
         .handleAction(
-            DEFAULT_ACTION, ActionType.CLICK, DEFAULT_FRAME, view, LogData.getDefaultInstance());
+            eq(DEFAULT_ACTION), eq(ActionType.CLICK), eq(DEFAULT_FRAME), eq(view), same(logData));
     assertThat(view.getForeground()).isInstanceOf(RippleDrawable.class);
   }
 
   @Test
   public void testSetOnLongClickActions_success() {
-    ViewUtils.setOnClickActions(LONG_CLICK_ACTIONS, view, mockFrameContext);
+    LogData logData = LogData.newBuilder().build();
+    ViewUtils.setOnClickActions(LONG_CLICK_ACTIONS, view, mockFrameContext, logData);
 
     view.performLongClick();
     verify(mockActionHandler)
         .handleAction(
-            DEFAULT_ACTION,
-            ActionType.LONG_CLICK,
-            DEFAULT_FRAME,
-            view,
-            LogData.getDefaultInstance());
+            eq(DEFAULT_ACTION),
+            eq(ActionType.LONG_CLICK),
+            eq(DEFAULT_FRAME),
+            eq(view),
+            same(logData));
     assertThat(view.getForeground()).isInstanceOf(RippleDrawable.class);
   }
 
@@ -187,7 +189,8 @@
     view.setOnClickListener(mockListener);
     assertThat(view.hasOnClickListeners()).isTrue();
 
-    ViewUtils.setOnClickActions(Actions.getDefaultInstance(), view, mockFrameContext);
+    ViewUtils.setOnClickActions(
+        Actions.getDefaultInstance(), view, mockFrameContext, LogData.getDefaultInstance());
 
     assertViewNotClickable();
     assertThat(view.getForeground()).isNull();
@@ -198,7 +201,8 @@
     view.setOnLongClickListener(mockLongClickListener);
     assertThat(view.isLongClickable()).isTrue();
 
-    ViewUtils.setOnClickActions(Actions.getDefaultInstance(), view, mockFrameContext);
+    ViewUtils.setOnClickActions(
+        Actions.getDefaultInstance(), view, mockFrameContext, LogData.getDefaultInstance());
 
     assertThat(view.isLongClickable()).isFalse();
     assertThat(view.getForeground()).isNull();
@@ -232,8 +236,10 @@
             .setOnLongClickAction(DEFAULT_ACTION)
             .build(),
         view,
-        mockFrameContext);
-    ViewUtils.setOnClickActions(Actions.getDefaultInstance(), view, mockFrameContext);
+        mockFrameContext,
+        LogData.getDefaultInstance());
+    ViewUtils.setOnClickActions(
+        Actions.getDefaultInstance(), view, mockFrameContext, LogData.getDefaultInstance());
 
     assertViewNotClickable();
     assertThat(view.isLongClickable()).isFalse();