Change _get_controller_config to _get_merged_config, so it applies to all multi-context configs

Bug: None
Test: local acts tests and unit tests
Change-Id: I8073b2335d0ef24f8582b5deac92e0591c23f81a
diff --git a/acts/framework/acts/test_utils/instrumentation/instrumentation_base_test.py b/acts/framework/acts/test_utils/instrumentation/instrumentation_base_test.py
index d0e7948..fe00d33 100644
--- a/acts/framework/acts/test_utils/instrumentation/instrumentation_base_test.py
+++ b/acts/framework/acts/test_utils/instrumentation/instrumentation_base_test.py
@@ -140,25 +140,51 @@
         """Clean up device after test completion."""
         pass
 
-    def _get_controller_config(self, controller_name):
-        """Get the controller config from the instrumentation config, at the
-        level of the current test class or test case.
+    def _get_merged_config(self, config_name):
+        """Takes the configs with config_name from the base, testclass, and
+        testcase levels and merges them together. When the same parameter is
+        defined in different contexts, the value from the most specific context
+        is taken.
+
+        Example:
+            self._instrumentation_config = {
+                'sample_config': {
+                    'val_a': 5,
+                    'val_b': 7
+                },
+                'ActsTestClass': {
+                    'sample_config': {
+                        'val_b': 3,
+                        'val_c': 6
+                    },
+                    'acts_test_case': {
+                        'sample_config': {
+                            'val_c': 10,
+                            'val_d': 2
+                        }
+                    }
+                }
+            }
+
+            self._get_merged_config('sample_config') returns
+            {
+                'val_a': 5,
+                'val_b': 3,
+                'val_c': 10,
+                'val_d': 2
+            }
 
         Args:
-            controller_name: Name of the controller config to fetch
-        Returns: The controller config, as a ConfigWrapper
+            config_name: Name of the config to fetch
+        Returns: The merged config, as a ConfigWrapper
         """
+        merged_config = self._instrumentation_config.get_config(
+            config_name)
+        merged_config.update(self._class_config.get_config(config_name))
         if self.current_test_name:
-            # Return the testcase level config, used for setting up test
             case_config = self._class_config.get_config(self.current_test_name)
-            return case_config.get_config(controller_name)
-        else:
-            # Merge the base and testclass level configs, used for setting up
-            # class.
-            merged_config = self._instrumentation_config.get_config(
-                controller_name)
-            merged_config.update(self._class_config.get_config(controller_name))
-            return merged_config
+            merged_config.update(case_config.get_config(config_name))
+        return merged_config
 
     def adb_run(self, cmds):
         """Run the specified command, or list of commands, with the ADB shell.
diff --git a/acts/framework/tests/test_utils/instrumentation/instrumentation_base_test_test.py b/acts/framework/tests/test_utils/instrumentation/instrumentation_base_test_test.py
index 04ac8e8..0a3ddde 100755
--- a/acts/framework/tests/test_utils/instrumentation/instrumentation_base_test_test.py
+++ b/acts/framework/tests/test_utils/instrumentation/instrumentation_base_test_test.py
@@ -29,11 +29,13 @@
         'lvl2': {'file1': 'FILE'}
     },
     'MockController': {
-        'param1': 1
+        'param1': 1,
+        'param2': 4
     },
     'MockInstrumentationBaseTest': {
         'MockController': {
-            'param2': 2
+            'param2': 2,
+            'param3': 5
         },
         'test_case': {
             'MockController': {
@@ -83,21 +85,21 @@
         controller config for the current test case.
         """
         self.instrumentation_test.current_test_name = 'test_case'
-        config = self.instrumentation_test._get_controller_config(
+        config = self.instrumentation_test._get_merged_config(
             'MockController')
-        self.assertNotIn('param1', config)
-        self.assertNotIn('param2', config)
-        self.assertIn('param3', config)
+        self.assertEqual(config.get('param1'), 1)
+        self.assertEqual(config.get('param2'), 2)
+        self.assertEqual(config.get('param3'), 3)
 
     def test_get_controller_config_for_test_class(self):
         """Test that _get_controller_config returns the controller config for
         the current test class (while no test case is running).
         """
-        config = self.instrumentation_test._get_controller_config(
+        config = self.instrumentation_test._get_merged_config(
             'MockController')
-        self.assertIn('param1', config)
-        self.assertIn('param2', config)
-        self.assertNotIn('param3', config)
+        self.assertEqual(config.get('param1'), 1)
+        self.assertEqual(config.get('param2'), 2)
+        self.assertEqual(config.get('param3'), 5)
 
 
 if __name__ == '__main__':